dav*_*xie 5 google-api google-oauth
我尝试在我的网站上使用Google登录,但是,它一直给我400错误.
我引用了这篇文章:https://developers.google.com/identity/sign-in/web/sign-in,我的代码非常简单:
<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>
Run Code Online (Sandbox Code Playgroud)
当我点击登录按钮时,它弹出一个窗口,登录后,它给了我400错误,如下所示:
400. That’s an error.
The requested URL was not found on this server. That’s all we know.
Run Code Online (Sandbox Code Playgroud)
我想这是重定向问题,但我不知道如何配置它.所以我查了url它还给了我:
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
Run Code Online (Sandbox Code Playgroud)
为什么redirect_uri"storagerelay://http/127.0.0.1:8000?id%3Dauth867179"?
小智 1
嗨,我遇到了完全相同的问题。
关于我的情况,问题是 OAuth 尝试重定向到“127.0.0.1?id=authxxxxx”的 url,其中 xxxxx 是随机的 5 位数字。
因此,我在 Redirect URI Google Developers Console 添加了以下四个 url。我不确定哪一个符合规则,但我可以使用以下解决方法
(1) http://127.0.0.1/ *
(2) https of (1)
(3) http://127.0.0.1
(4) https共 (3)
希望它也适合你。
| 归档时间: |
|
| 查看次数: |
11704 次 |
| 最近记录: |