我目前正在开发一个管理系统来编辑网站内容,并且需要一个登录系统,允许我检查用户是否在某个Google群组中,因此我使用的是Google登录平台(作为Google Identity Toolkit的一部分) )但是,当我点击“登录”并选择帐户时,小部件只显示“错误400:这就是我们所知道的” .
我已经多次从头开始重写了登录系统,遵循Google Sign In网站上的文档 . 我的代码如下:
头:
<script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="google-signin-client_id" content="User-ID.apps.googleusercontent.com">
身体:
<div class="g-signin2" data-onsucess="onSignIn"></div>
<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>
我的Google Developers项目设置为接受来自localhost和127.0.0.1的Javascript来源(即使它们是相同的),并且没有重定向URI,因为它们不是必需的 .
我查看过谷歌状态网站,一切似乎都很好,以及寻求我的信息通信技术老师的帮助,所以我完全陷入困境,任何帮助将不胜感激!
提前致谢 :)
2 回答
更新:从浏览器中的127.0.0.1切换到localhost似乎已经解决了问题,很奇怪,但只要它有效!
在Google开发人员凭据中使用
http://127.0.0.1
来源JavaScript根本不起作用 .