我有拿谷歌登入在我的網站:如何調用getBasicProfile()的谷歌登錄只有按鈕點擊谷歌?
<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('Image URL: ' + profile.getImageUrl());
//console.log('Name: ' + profile.getName());
//console.log('Email: ' + profile.getEmail());
var user_uname = profile.getName();
var user_email = profile.getEmail();
alert(user_uname);
}
</script>
,這裏是一個按鈕登錄谷歌:
<div class="g-signin2" data-onsuccess="onSignIn"></div>
我想給用戶谷歌登入,但問題是,每當頁面加載onSignIn()函數會自動調用。 我只需要點擊按鈕。有誰能夠幫助我?