首页 文章

Google中的idpiframe_initialization_failed从Localhost登录

提问于
浏览
5

我正在尝试按照 this link 创建一个谷歌登录按钮 . 到目前为止,帐户选择对话框即将到来,但之后我不会在页面加载时收到此错误,

"idpiframe_initialization_failed", details: "Not a valid origin for the client: http://localhos…itelist this origin for your project's client ID."
details: "Not a valid origin for the client: http://localhost has not been whitelisted for client ID 386404527657-q4ss06np5g27dllq5ds7aif42udkh7e5.apps.googleusercontent.com. Please go to https://console.developers.google.com/ and whitelist this origin for your project's client ID."

这是代码,

<html lang="en">
  <head>
    <meta name="google-signin-scope" content="profile email">
    <meta name="google-signin-client_id" content="YOUR_CLIENT_ID.apps.googleusercontent.com">
    <script src="https://apis.google.com/js/platform.js" async defer></script>
  </head>
  <body>
    <div class="g-signin2" data-onsuccess="onSignIn" data-theme="dark"</div>
    <script>
      function onSignIn(googleUser) {
        // Useful data for your client-side scripts:
        var profile = googleUser.getBasicProfile();
        console.log("ID: " + profile.getId()); // Don't send this directly to your server!
        console.log('Full Name: ' + profile.getName());
        console.log('Given Name: ' + profile.getGivenName());
        console.log('Family Name: ' + profile.getFamilyName());
        console.log("Image URL: " + profile.getImageUrl());
        console.log("Email: " + profile.getEmail());

        // The ID token you need to pass to your backend:
        var id_token = googleUser.getAuthResponse().id_token;
        console.log("ID Token: " + id_token);
      };
    </script>
  </body>
</html>

我真的需要解决这个问题,并在我的控制台中获得结果 . 我不知道接下来要做什么来解决这个问题 . 需要帮助,谢谢!

1 回答

  • 7

    我有这个问题,this solution为我工作 .

    简而言之:清除浏览器缓存 .

    在Chrome中:设置→高级→清除浏览数据→缓存的图像和文件

相关问题