尝试在Google应用引擎上使用Google身份工具包时出现SSL错误

时间:2016-01-15 01:26:03

标签: google-app-engine google-identity-toolkit

我在尝试连接身份工具包时遇到SSL错误。我只是坚持指南,但我必须错过一些东西。

我确实在webapp文件夹中包含了p12键和gitkit-server-config.json

这是我的index.html:

<html>
<head>
    <!-- Begin custom code copied from Developer Console -->
    <!-- Note: this is just an example. The html you download from Developer Console will be tailored for your site -->
    <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: "https://localhost:8080/callback",
          signOutUrl: "/",
          // Optional - Begin the sign-in flow in a popup window
          //popupMode: true,

          // Optional - Begin the sign-in flow immediately on page load.
          //            Note that if this is true, popupMode param is ignored
          //loginFirst: true,

          // Optional - Cookie name (default: gtoken)
          //            NOTE: Also needs to be added to config of ‘widget
          //                  page’. See below
          //cookieName: ‘example_cookie’,
        }
      );
    </script>
    <!-- End custom code copied from Developer Console -->
</head>
<body>
<!-- Begin sign in button widget -->
<div id="navbar"></div>
<!-- End sign in button widget -->
</body>
</html>

这是我的callback.html:

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <!-- Copy and paste here the "Widget javascript" you downloaded from Developer Console as gitkit-widget.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">
      var config =
{
  "widgetUrl": "http://localhost:8080/index2.html",
  "signInSuccessUrl": "/",
  "signOutUrl": "/",
  "oobActionUrl": "/",
  "apiKey": "AIzaSyDIXrYgOzLzWyQ8E4lMQ4yYf-MQkkC-KVg",
  "siteName": "this site",
  "signInOptions": ["password","google","facebook"]
};

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

    <!-- End modification -->

</head>
<body>

<!-- Include the sign in page widget with the matching 'gitkitWidgetDiv' id -->
<div id="gitkitWidgetDiv"></div>
<!-- End identity toolkit widget -->

</body>
</html> 

1 个答案:

答案 0 :(得分:0)

开发服务器不支持SSL。

在开发服务器上进行测试时,您可以在网址中使用http://localhost...代替https://localhost...