0

运行 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 不将其识别为有效?

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

问候。

4

1 回答 1

0

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

于 2015-11-19T19:13:42.617 回答