0
我想使用谷歌登录为我的应用程序。一些工作站由多个用户共享,因此在用户之间快速切换的能力非常重要。如何切换用户?谷歌登录网站
按钮的符号似乎让这一点。即如果用户被“登录”,点击登录按钮将显示“选择帐户”对话框。
我可以简单地通过具有按钮出现在每个页面实现这个快速变化的功能。
问题然而,每一个页面加载时间的“成功”事件触发。这意味着我将在每次加载页面时进行身份验证和创建会话。这似乎效率低下。
有没有,让我来区分用户是否已明确登录VS谷歌检查,看看是否在用户登录的事件?
代码下面是按照文档。我已经阅读了API文档,但无法弄清楚。
感谢
<script src="https://apis.google.com/js/platform.js" async defer></script>
<script>
function onSignIn(googleUser) {
var profile = googleUser.getBasicProfile();
console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
console.log('Name: ' + profile.getName());
console.log('Image URL: ' + profile.getImageUrl());
alert('Email: ' + profile.getEmail());
}
</script>
<meta name="google-signin-client_id" content="173138624956-ajom95asqea9p8f3ob0ntjvaalhf5r99.apps.googleusercontent.com">
<div class="g-signin2" data-onsuccess="onSignIn"></div>