【发布时间】:2018-06-17 09:49:02
【问题描述】:
我在自己的网站上使用 Google Identity Toolkit(网页版)已有 2 年多了。最近我发现密码重置流程坏了。当我尝试“忘记密码”时,选中 recaptcha 复选框并单击继续,我收到错误消息“请求失败。请重试。”
在控制台中我看到了这个:
[ 28.949s] [identitytoolkit] Error: Invalid JSON string: Password reset email sent successfully.
Gj @ gitkit.js:254
Ej.addLogRecord @ gitkit.js:254
Zi.log @ gitkit.js:237
R @ gitkit.js:254
(anonymous) @ gitkit.js:255
Yc @ gitkit.js:44
g.dispatchEvent @ gitkit.js:42
tj @ gitkit.js:247
lj.onReadyStateChangeEntryPoint_ @ gitkit.js:245
lj.onReadyStateChange_ @ gitkit.js:245
XMLHttpRequest.send (async)
lj.send @ gitkit.js:242
Mj @ gitkit.js:255
Lj.requestRpEndpoint @ gitkit.js:256
g.requestRpEndpoint @ gitkit.js:259
(anonymous) @ gitkit.js:4
N @ gitkit.js:190
Fh @ gitkit.js:190
Sm @ gitkit.js:334
(anonymous) @ gitkit.js:335
(anonymous) @ gitkit.js:80
(anonymous) @ gitkit.js:77
Yc @ gitkit.js:44
g.dispatchEvent @ gitkit.js:42
fd @ gitkit.js:47
ed.handleClick_ @ gitkit.js:47
Uc @ gitkit.js:39
Rc @ gitkit.js:41
Pc.b @ gitkit.js:37
即使错误提示“电子邮件发送成功”,它也没有发送。我不知道它已经坏了多久。我昨天才发现的。
我正在使用这个脚本:
https://www.gstatic.com/authtoolkit/js/gitkit.js 在我的网站上。
我希望来自 Google 身份工具包团队的人可以在这方面提供帮助。
更新 1:
服务器端代码:
OobResponse oobResponse = gitkitClient.getOobResponse(request);
OobAction oobAction = oobResponse.getOobAction();
// For DEBUG
logger.info("oobAction : " + oobAction);
String action = request.getParameter("action");
logger.info("action : " + action); // returns null
logger.info("response: " + request.getParameter("response")); // returns a long string
logger.info("responseBody : " + oobResponse.getResponseBody()); // returns {"error": "CAPTCHA_CHECK_FAILED" }
logger.info("email : " + oobResponse.getEmail()); // returns null
// If reset password
if (OobAction.RESET_PASSWORD.equals(oobAction)) {
Optional<String> forgotPasswordLinkOpt = oobResponse.getOobUrl();
String passwordResetLink = forgotPasswordLinkOpt.get();
sendMailService.sendPasswordResetEmail(oobResponse.getEmail(), passwordResetLink);
return(oobResponse.getResponseBody());
}
oobAction 将变为null,因此不会发送链接。但是action 的值为resetPassword。 'responseBody' 正在返回
{"error": "CAPTCHA_CHECK_FAILED" }。我是否需要在我的末尾为 recaptcha 字符串做一些配置?
我正在使用来自 Maven 存储库的 gitkitclient v1.2.7:
https://mvnrepository.com/artifact/com.google.identitytoolkit/gitkitclient
【问题讨论】:
-
嘿@DFB,密码重置在 GITKit 的服务器端处理。你能检查一下服务器端抛出了什么错误吗?这看起来与客户端无关。
-
@bojeil 感谢您的帮助。是的,这确实是服务器端代码的一个问题,因为 oobAction 是空的。你能帮我找出问题所在吗?在“UPDATE 1”标题下查看我的更新。
-
@bojeil 我发布了更多更新。 recaptcha 字符串可能有问题。请注意,我的服务器正在使用
appspot.com域,而客户端正在我自己的自定义域上运行。 -
@bojeil 显然,这也是在这个线程上为 PHP 客户端报告的,但在这种情况下它会自行解决:stackoverflow.com/questions/50691691/…
-
你能提供你的项目编号吗?