Javascript 谷歌登录不';我不总是工作
我正在实现此处描述的Google登录的服务器端流程: 我的问题是,在某些计算机上,在某些浏览器中,它不起作用Javascript 谷歌登录不';我不总是工作,javascript,google-api,google-signin,Javascript,Google Api,Google Signin,我正在实现此处描述的Google登录的服务器端流程: 我的问题是,在某些计算机上,在某些浏览器中,它不起作用 第一台电脑,谷歌Chrome44.0.2403.157M-works 第一台计算机,Microsoft Edge 20.10525.0.0-永远无法工作 第一台电脑,即11-永远不会工作 第二台电脑,谷歌Chrome,同样的版本——来自文档的版本(见下图)总是有效的,在网站上实现——工作过一次,不再有效 这是一个我正在测试的代码。它的大部分内容都是抄袭的 代码的预期行为:登录后,按
- 第一台电脑,谷歌Chrome44.0.2403.157M-works
- 第一台计算机,Microsoft Edge 20.10525.0.0-永远无法工作
- 第一台电脑,即11-永远不会工作
- 第二台电脑,谷歌Chrome,同样的版本——来自文档的版本(见下图)总是有效的,在网站上实现——工作过一次,不再有效
函数start(){
load('auth2',function(){
auth2=gapi.auth2.init({
客户端id:'655082111777-8dlr2thnsn9a1v74f55ku2gs1gjjcpaj.apps.googleusercontent.com',
//除了“配置文件”和“电子邮件”之外,还可以请求范围
//范围:“附加范围”
});
});
}
使用谷歌登录
$(“#登录按钮”)。单击(函数(){
//signInCallback在步骤6中定义。
auth2.grantoflineaccess({'redirect_uri':'postmessage'});
});
函数signInCallback(authResult){
$('#result')。追加(“控制台中的结果”);
console.log(authResult);
}
请提供有关如何使其在任何地方始终有效的任何建议
<!-- The top of file index.html -->
<html itemscope itemtype="http://schema.org/Article">
<head>
<!-- BEGIN Pre-requisites -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js">
</script>
<script src="https://apis.google.com/js/client:platform.js?onload=start" async defer>
</script>
<!-- END Pre-requisites -->
<!-- Continuing the <head> section -->
<script>
function start() {
gapi.load('auth2', function() {
auth2 = gapi.auth2.init({
client_id: '655082111777-8dlr2thnsn9a1v74f55ku2gs1gjjcpaj.apps.googleusercontent.com',
// Scopes to request in addition to 'profile' and 'email'
//scope: 'additional_scope'
});
});
}
</script>
</head>
<body>
<!-- Add where you want your sign-in button to render -->
<!-- Use an image that follows the branding guidelines in a real app -->
<button id="signinButton">Sign in with Google</button>
<script>
$('#signinButton').click(function() {
// signInCallback defined in step 6.
auth2.grantOfflineAccess({'redirect_uri': 'postmessage'}).then(signInCallback);
});
</script>
<div id="result"></div>
<!-- Last part of BODY element in file index.html -->
<script>
function signInCallback(authResult) {
$('#result').append("result in console");
console.log(authResult);
}
</script>
</body>
</html>