身份工具箱不工作-错误代码:IDP的错误响应
Identity Toolkit does not work - Error code: Bad response from IDP
我目前无法解决的问题是bad response from IDP
,原因应该是缺乏mode=select
,但我现在不知道mode=select
必须实施的页面
事实上,我已经将代码添加到两个独立的页面中,第一个是index.php,它执行以下操作:
<script type="text/javascript" src="//www.gstatic.com/authtoolkit/js/gitkit.js"></script>
<script type="text/javascript">
var config = {
apiKey: 'AIzaSyAaMAfu7S2AITODrGJzVkIYBXlZR3FYhuQ',
signInSuccessUrl: 'http://www.lascuolacheverra.org/signin?mode=select', // i tried to add the `mode=select here`
signInOptions: ["google", "password"],
idps: ["Google", "AOL", "Microsoft", "Yahoo", "Facebook"],
oobActionUrl: '/',
siteName: 'La scuola che verrà A.P.S.',
// Optional - function called after sign in completes and before
// redirecting to signInSuccessUrl. Return false to disable
// redirect.
// callbacks: {
// signInSuccess: function(tokenString, accountInfo,
// opt_signInSuccessUrl) {
// return true;
// }
// },
// Optional - key for query parameter that overrides
// signInSuccessUrl value (default: 'signInSuccessUrl')
// queryParameterForSignInSuccessUrl: 'url'
// Optional - URL of site ToS (linked and req. consent for signup)
tosUrl: 'http://www.lascuolacheverra.org/privacypolicy.html',
// Optional - URL of callback page (default: current url)
// callbackUrl: 'http://example.com/callback',
// Optional - Cookie name (default: gtoken)
// NOTE: Also needs to be added to config of the ‘page with
// sign in button’. See above
// cookieName: ‘example_cookie’,
// Optional - UI configuration for accountchooser.com
acUiConfig: {
title: 'Sign in to lascuolacheverra.org',
favicon: 'http://www.lascuolacheverra.org/favicon.ico',
branding: 'http://www.lascuolacheverra.org/images/lascuolacheverra.jpg'
},
// Optional - Function to send ajax POST requests to your Recover URL
// Intended for CSRF protection, see Advanced Topics
// url - URL to send the POST request to
// data - Raw data to include as the body of the request
//completed - Function to call with the object that you parse from
// the JSON response text. {} if no response
/*ajaxSender: function(url, data, completed) {
},
*/
};
// The HTTP POST body should be escaped by the server to prevent XSS
window.google.identitytoolkit.start(
'#gitkitWidgetDiv', // accepts any CSS selector
config,
'{{ POST_BODY }}');
</script>
<!-- End modification -->
代码的第二部分位于另一个index.php中,执行以下操作:
<!DOCTYPE html>
<html>
<head>
<!-- Copy and paste here the "Sign-in button javascript" you downloaded from Developer Console as gitkit-signin-button.html -->
<script type="text/javascript" src="//www.gstatic.com/authtoolkit/js/gitkit.js"></script>
<link type=text/css rel=stylesheet href="//www.gstatic.com/authtoolkit/css/gitkit.css" />
<script type=text/javascript>
window.google.identitytoolkit.signInButton(
'#navbar', // accepts any CSS selector
{
widgetUrl: "/widget",
signOutUrl: "/",
}
);
</script>
<!-- End configuration -->
</head>
<body>
<!-- Include the sign in button widget with the matching 'navbar' id -->
<div id="navbar"></div>
<!-- End identity toolkit widget -->
<p>
{{ CONTENT }}
</p>
</body>
</html>
我想知道我如何才能正确使用mode=select
,因为今天身份工具包可用于我的主页,但由于这个错误,我不能充分使用它。
您需要创建两个页面。比如url1和url2
url1,其中包含您的登录按钮运行:
window.google.identitytoolkit.signInButton ()
设置widgetUrl为url2
在url2中,您可以运行:
window.google.identitytoolkit.start ()
将signInSuccessUrl设置为url1
不要添加?mode=select到小部件url。当点击登录按钮时,它会自动将其附加到该url并重定向到那里。
signInSuccessUrl:'http://www.lascuolacheverra.org/signin?mode=select',//我尝试添加
mode=select here
不应该指向/signin
页。也许指向/
或/signed-in
。
同时,删除
//signInOptions: ["google", "password"],//<——这显然掩盖了idps
国内流离失所者:("谷歌","美国在线"、"微软","雅虎","Facebook"],
我对此做了一些测试,如果我添加signInOptions,那么idps被忽略,您最终只能使用google和密码登录。
显然,只有使用signInOptions才能做到这一点。我在其他例子中读过idps而不是signInOptions,我成功地使用了idps。
Update我读错了代码。我认为'signin
是显示小部件的页面,教程将其放在'widget
下。我的错误,因为在我的项目中,我用'secure-sign-in
代替'widget
。因此,如果您的'signin
页面不是'widget
页面,那么您的代码已经OK了。在任何情况下,您都应该删除?mode=select
,因为这只用于'widget
,并且是由window.google.identitytoolkit.signInButton
函数自动添加的。
我刚刚遇到了同样的错误"错误代码:来自IDP的不良响应。"
如上所述,有两种可能:
- 创建一个页面,只有一个登录按钮和另一个页面,前一个重定向到按钮点击
- 将
"?mode=select"
附加到url作为查询参数 -
在路由中重定向,例如
app.get("/login", function(req, res) { res.redirect("/login?mode=select"); }
gitkit.js从浏览器中提取window.location.href
.
- Node.js v6.2.0类扩展不是函数错误
- Jquery菜单操作不稳定,定位不正确,存在一般错误
- document.open/document.write没有正确地清除chrome中的文档——这是chrome的错误吗
- 试图在引导模式内动态生成图表,得到offsetWidth错误
- 为什么会出现错误;未捕获的类型错误:undefined不是函数;
- 我如何修复包含在captcha的addthis中的错误
- 同样,同样的错误'ahorcado.js:26未捕获类型错误:无法读取属性'beginPath'
- 节点是否需要模块传递带有方括号的arg?这是个错误吗
- Webpack/Rect:遵循egghead.io教程,但出现错误:您可能需要一个合适的加载程序来处理此文件类型
- CKFinder 3为所选文件返回错误的URL
- 同位素库错误:未捕获错误无布局模式包装生产线8
- 铬:“;未捕获的语法错误:意外的标记:"
- 如何通过自己获得Chrome扩展的用户反馈/错误报告
- 相位器状态未捕获参考错误
- /undefined在我的404错误日志中多次出现
- Javascript未捕获语法错误意外的标识符错误
- javascript:如何在antlr生成的Lexer中进行错误处理
- Angularjs工厂注入错误
- 可以设置“;文件名"发生错误时显示的内联脚本标记的
- 身份工具箱不工作-错误代码:IDP的错误响应