【问题标题】:Identity Toolkit unrecognized config parameterIdentity Toolkit 无法识别的配置参数
【发布时间】:2015-11-19 09:44:25
【问题描述】:

运行 gitkit 小部件时出现以下错误:

[  0.004s] [identitytoolkit] Invalid config: "callbackUrl"rj @ gitkit.js:236pj.addLogRecord @ gitkit.js:236Li.log @ gitkit.js:219Q @ gitkit.js:236zl @ gitkit.js:273(anonymous function) @ gitkit.js:306(anonymous function) @ gitkit-widget.html?mode=select:29

我的代码如下:

var config = {
            signInSuccessUrl: "/",
            apiKey: "AIzaSyAt3gELMqBCdn9U8FLSXbtCJbizHSX3kng",
            siteName: "Google Apps Training",
            signInOptions: ["google","facebook", "microsoft"],
            //idps: ["google", "facebook", "microsoft"],
            /*callbacks: {
                signInSuccess: function(tokenString, accountInfo, signInSuccessUrl) {

                    console.log("callback");
                    console.log(tokenString);
                    console.log(accountInfo);
                    console.log(signInSuccessUrl);

                    return true;
                }
            },*/
            callbackUrl: "http://localhost:8080/signin"
        };

        // The HTTP POST body should be escaped by the server to prevent XSS
        window.google.identitytoolkit.start(
                '#gitkitWidgetDiv', // accepts any CSS selector
                config);

这是https://developers.google.com/identity/toolkit/web/setup-frontend 提供的 gitkit 文档示例

var config = {
          apiKey: 'AIza...',
          signInSuccessUrl: '/',
          signInOptions: ["google", "password"],
          oobActionUrl: '/',
          siteName: 'this site',

          // 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://example.com/terms_of_service',

          // 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 example.com',
               favicon: 'http://example.com/favicon.ico',
               branding: 'http://example.com/account_choooser_branding'
           },
           */

           // 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,
          'JAVASCRIPT_ESCAPED_POST_BODY');

那么,如果最新的示例代码显示“callbackUrl”作为可用的可选参数,为什么gitkit js 不识别它为有效?

有没有可以检查所有可用参数的地方?

问候。

【问题讨论】:

    标签: google-identity-toolkit


    【解决方案1】:

    callbackUrl 不再是有效字段。文档不正确,将及时更新。对此我们深表歉意,并感谢您向我们提出这个问题。小部件当前 url 将自动用作 IDP 回调 url,因此请务必在您的 IDP(google、facebook 等)oauth 客户端设置(回调 url)中添加您的小部件 url。

    【讨论】:

    • 感谢您的回复。如果我使用的是 Google Endpoints 并且想将回调重定向到某个端点,该怎么办?这还有可能吗?是否有任何使用 Google Endpoints 的在线示例代码?
    • 我不确定您要做什么。如果您要重定向到 google 端点,您可以选择在 gitkit 配置字段中指定该 url:signInSuccessUrl 或通过登录成功回调函数手动重定向。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-23
    • 1970-01-01
    • 1970-01-01
    • 2022-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多