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>