使用谷歌与JavaScript登录

时间:2018-03-27 13:33:34

标签: javascript google-signin

我希望允许用户使用他们的Google帐户登录我的系统。 所以我正在使用Google登录Google。

我的问题是当用户打开登录页面登录时Google会在登录页面加载时自动生效。我希望用户在按下Google按钮登录时登录其他

是登录按钮

<div class="g-signin2" data-longtitle="false" data-onsuccess="Google_signIn" data-theme="dark" data-width="200"></div>

这是javascript代码

function Google_signIn(googleData) 
{
    var profile = googleData.getBasicProfile(); //get google profile details


    //update to database
//  var islogged=googleData.isSignedIn();//alert(islogged);
//  if(islogged==false)
    update_user_data(profile);

}


function update_user_data(response) 
{alert('ok');
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<html >
<head>
<!-- start: Meta -->
</script>
<script src="https://apis.google.com/js/platform.js" async defer></script>

<!-- start: Mobile Specific -->

<!-- end: Mobile Specific -->

<meta name="google-signin-client_id" content="636950137786-j3siaftgshtf9iajhfgfdxhgjf1.apps.googleusercontent.com">
</head>
<body>
<div id="google_login_box">
<div class="g-signin2" data-longtitle="false" data-onsuccess="Google_signIn" data-theme="dark" data-width="200"></div>
</div>
</body>

如何仅在用户按下按钮

时才能使此代码正常工作

0 个答案:

没有答案
相关问题