如何解决无法使用 gapi.auth2.getAuthInstance().signOut() 注销
我正在尝试按照此处给出的说明为我的 Web 应用程序实现 google 登录: https://developers.google.com/identity/sign-in/web/sign-in
我的Html页面如下:
<html lang="en">
<head>
<Meta name="google-signin-scope" content="profile email">
<Meta name="google-signin-client_id" content="xdydycdskeldlsldlkkekdd.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script></head>
<body>
<div class="g-signin2" data-onsuccess="onSignIn" data-theme="dark"></div>
<a href="#" onclick="signOut();">Sign out</a>
<script>
function signOut() {
var auth2 = gapi.auth2.getAuthInstance();
alert(auth2);
auth2.signOut().then(function () {
console.log('User signed out.');
alert('User signed out.');
});
}
</script>
<script>
function onSignIn(googleUser) {
// Useful data for your client-side scripts:
var profile = googleUser.getBasicProfile();
alert(profile);
console.log("ID: " + profile.getId()); // Don't send this directly to your server!
console.log('Full Name: ' + profile.getName());
console.log('Given Name: ' + profile.getGivenname());
console.log('Family Name: ' + profile.getFamilyName());
console.log("Image URL: " + profile.getimageUrl());
console.log("Email: " + profile.getEmail());
// The ID token you need to pass to your backend:
var id_token = googleUser.getAuthResponse().id_token;
}
</script>
</body>
</html>
登录有效,我收到一个 gmail 弹出窗口,我输入凭据并登录。但是当我点击退出时,它根据警报将消息显示为 '用户退出',但是如果我再次点击登录按钮,它会在没有任何提示的情况下签名我设置的密码或 2 因素身份验证。谁能解释为什么会发生这种情况?另外,如果我连续点击退出,它每次都会给出'用户退出'的消息,有人可以帮我吗?谢谢
在其他浏览器(不包括 chrome)中,如 firefox,我在登录按钮点击时没有从 javascript 功能收到任何警报?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。