我沒有谷歌連接,讓用戶使用他們的谷歌帳戶登錄。防止谷歌自動觸發數據-onsuccess =「onSignIn」
我做什麼,創建一個按鈕
<div class="g-signin2 social_signin" data-onsuccess="onSignIn"></div>
然後創建onSignIn()
<script>
function onSignIn(googleUser) {
// Useful data for your client-side scripts:
var profile = googleUser.getBasicProfile();
console.log("ID: " + profile.getId()); // Don't send this directly to your server!
console.log("Name: " + profile.getName());
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;
console.log("ID Token: " + id_token);
};
</script>
然後該令牌發送到PHP服務器進行驗證和獲取數據。這工作正常。
但我的問題是,當用戶從我的網站註銷時,google會自動觸發'onSignIn'而不點擊我創建的按鈕。所以當用戶註銷時,用戶會自動重新登錄。
你能幫我在這裏防止這種自動登錄?或者我可以取消授權用戶?
這個方法我試過,但我不能夠觸發onSignin FUNC,我的意思一切工作正常,但是當我看到控制檯應該提供特定的輸出,但它沒有。可你告訴我程序! :) –
你能顯示一些代碼嗎? 似乎你缺少data-onsuccess =「onSignIn」 –
http://stackoverflow.com/questions/34724224/regarding-onsigningoogleuser這裏是 –