[英]Google Oauth2 sign in using javascript API is not working with IE
我正在使用Google oauth2 javascript API来对我的应用程序的用户进行身份验证。 在Firefox和chrome中可以正常工作,但在IE中则不能。 我曾在IE 8、9和10中尝试过,但徒劳无功。 我在网上搜索了很多,但是却没有找到任何解决方案。 我经历了stackoverflow问题14285480和14830177 。 如果这是google中的现有错误,那么还有其他替代方法吗? 我正在尝试下面的代码。 我没有足够的stackoverflow点来评论任何问题,因此请提出一个新问题。 请帮忙。
这是我的代码
<html>
<head>
<script type="text/javascript">
window.setTimeout(function() {
var po = document.createElement('script');
po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/client:plusone.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
},1000)();
function signinCallback(authResult) {
if (authResult['access_token']) {
document.getElementById('signinButton').setAttribute('style', 'display: none');
}
else if (authResult['error']) {
console.log('Sign-in state: ' + authResult['error']);
}
}
</script>
</head>
<body>
<span id="signinButton">
<span
class="g-signin"
data-callback="signinCallback"
data-clientid="my clinetid"
data-cookiepolicy="single_host_origin"
data-requestvisibleactions="http://schemas.google.com/AddActivity"
data-scope="https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile">
</span>
</span>
</body>
</html>
尝试这个。
<html>
<head>
<script type="text/javascript">
function signinCallback(authResult) {
if (authResult['access_token']) {
document.getElementById('signinButton').setAttribute('style', 'display: none');
}
else if (authResult['error']) {
console.log('Sign-in state: ' + authResult['error']);
}
}
</script>
</head>
<body>
<span id="signinButton">
<span
class="g-signin"
data-callback="signinCallback"
data-clientid="my clinetid"
data-cookiepolicy="single_host_origin"
data-requestvisibleactions="http://schemas.google.com/AddActivity"
data-scope="https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile">
</span>
</span>
<script type="text/javascript">
var po = document.createElement('script');
po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/client:plusone.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
</script>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.