身份工具包不起作用-错误代码:来自IDP的错误响应 [英] Identity Toolkit does not work - Error code: Bad response from IDP

查看:64
本文介绍了身份工具包不起作用-错误代码:来自IDP的错误响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前无法解决的问题是bad response from IDP,原因可能是缺少mode=select,但是我现在不知道必须执行mode=select的页面

The problem that I am currently unable to solve is bad response from IDP and the cause is supposed to be the lack of mode=select but I'm unaware now about the page where the mode=select must be implemented

事实上,我已将代码添加到两个单独的页面中,第一个是index.php,它执行以下操作:

As a matter of fact I have added the code into two separated pages, the first one is index.php which does the following:

<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中,并执行以下操作:

The second part of the code is in another index.php and does the following:

<!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,因为从今天开始,身份工具包可用于我的主页,但是由于此错误,我无法充分利用它.

I would like to know how I have to proceed in order to correctly use mode=select since as of today Identity Toolkit is available to my homepage but I can't use it to the fullest because of this bug.

推荐答案

signInSuccessUrl: ' http://www.lascuolacheverra.org/signin?mode=select ',//我试过了 添加mode=select here

signInSuccessUrl: 'http://www.lascuolacheverra.org/signin?mode=select', // i tried to add the mode=select here

这不应指向/signin页.也许将其指向//signed-in.

This should not point to the /signin page. Maybe point it to / or /signed-in.

此外,删除

//signInOptions:["google",密码"],//<-这显然掩盖了idps

// signInOptions: ["google", "password"], // <-- this apparently masks out the idps

idps:["Google","AOL","Microsoft","Yahoo","Facebook"],

idps: ["Google", "AOL", "Microsoft", "Yahoo", "Facebook"],

我对此进行了一些测试,如果我添加了signInOptions,则idps被忽略,您最终只能使用google和密码登录.

I did some testing with this, and if I add signInOptions, then idps is ignored and you end up only being able to sign in with google and password.

显然仅使用signInOptions 这样的方法.在其他示例中,我已经阅读了idps而不是signInOptions,并且我成功地使用了idps.

Apparently only using signInOptions is the way to do it. I've read idps instead of signInOptions in other examples, and I'm using idps with success.

更新我有点读错了代码.我以为\signin是显示小部件的页面,教程将其放置在\widget下.我的错误是因为在我的项目中,我将\widget替换为\secure-sign-in.因此,如果您的\signin页面不是\widget页面,则您的代码已经确定.并且在任何情况下都应删除?mode=select,因为它仅用于\widget,并由window.google.identitytoolkit.signInButton函数自动添加.

Update I misread the code a bit. I thought \signin was the page showing the widget, which the tutorials place under \widget. My mistake because in my project I'm replacing \widget with \secure-sign-in. So, if your \signin page is not the \widget page then your code was already OK. And in any case you should remove the ?mode=select because this is only used for the \widget and is added automatically by the window.google.identitytoolkit.signInButton function.

这篇关于身份工具包不起作用-错误代码:来自IDP的错误响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆