Google登录无效 [英] Google Sign-in is not working

查看:512
本文介绍了Google登录无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试将Google Sign-in用于我的网站,但它一直给我400个错误。 我引用了以下文章: https://developers.google.com/identity/sign-in/web/sign-in ,我的代码非常简单:

 < html> 
< head>
< title>测试Google登入< / title>
< script src =https://apis.google.com/js/platform.jsasync defer>< / script>
< meta name =google-signin-client_idcontent =< CHANGE IT>>
< script>
函数onSignIn(googleUser){
var profile = googleUser.getBasicProfile();
console.log('ID:'+ profile.getId());
console.log('Name:'+ profile.getName());
console.log('Image URL:'+ profile.getImageUrl());
console.log('Email:'+ profile.getEmail());
}
< / script>
< / head>
< body>
< div class =g-signin2data-onsuccess =onSignIn>< / div>
< / body>
< / html>

当我点击登录按钮时,它弹出一个窗口,登录后它给了我400错误如下:

  400。这是一个错误。 

在此服务器上找不到请求的URL。我们知道的就这些。

我猜这是重定向问题,但我不知道如何配置它。所以我检查了它返回给我的网址:

  https://accounts.google.com/o/oauth2/auth?fetch_basic_profile =真放,范围=电子邮件+简介+的OpenID和放大器; RESPONSE_TYPE =许可急症= 3100087&放大器; REDIRECT_URI = storagerelay://http/127.0.0.1:8000 ID%3Dauth867179和放大器; ss_domain = HTTP://127.0.0.1:8000和放大器; CLIENT_ID = 378468243311-9dt7m9ufa9mee305j1b12815put5betb.apps.googleusercontent.com& openid.realm& hl = en& from_login = 1& as = 1b5f0a407ea58e11& pli = 1& authuser = 0 

为什么redirect_uristoragerelay://http/127.0.0.1:8000?id%3Dauth867179?

解决方案

您的代码现在应该可以正常工作。



Google解决了这个问题。带有斜杠的起源现在也被接受(Origin可以在Google Developers Console> APIs& auth> Credentials中设置)。


I tried to use Google Sign-in for my website, however, it keeps giving me 400 error.

I referenced this article: https://developers.google.com/identity/sign-in/web/sign-in, and my code is really simple:

<html>
<head>
  <title>Test Google Login</title>
  <script src="https://apis.google.com/js/platform.js" async defer></script>
  <meta name="google-signin-client_id" content="<CHANGE IT>">
  <script>
  function onSignIn(googleUser) {
    var profile = googleUser.getBasicProfile();
    console.log('ID: ' + profile.getId());
    console.log('Name: ' + profile.getName());
    console.log('Image URL: ' + profile.getImageUrl());
    console.log('Email: ' + profile.getEmail());
  }
  </script>
</head>
<body>
  <div class="g-signin2" data-onsuccess="onSignIn"></div>
</body>
</html>

When I click Sign-in button, it popups a window, and after logged in, it gave me 400 error as below:

400. That’s an error.

The requested URL was not found on this server. That’s all we know.

I guess it's redirect issue, but I don't know how to configure it. So I checked url it returned to me:

https://accounts.google.com/o/oauth2/auth?fetch_basic_profile=true&scope=email+profile+openid&response_type=permission&e=3100087&redirect_uri=storagerelay://http/127.0.0.1:8000?id%3Dauth867179&ss_domain=http://127.0.0.1:8000&client_id=378468243311-9dt7m9ufa9mee305j1b12815put5betb.apps.googleusercontent.com&openid.realm&hl=en&from_login=1&as=1b5f0a407ea58e11&pli=1&authuser=0

Why is redirect_uri "storagerelay://http/127.0.0.1:8000?id%3Dauth867179"?

解决方案

Your code should work now.

Google fixed this issue. Origins with a trailing slash are also accepted now (Origin can be set in Google Developers Console > APIs & auth > Credentials).

这篇关于Google登录无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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