如何检查用户是否已使用Google登录?

时间:2019-11-02 14:40:13

标签: javascript google-signin

我需要Google登录才能访问我的网站。我已经使用Google文档在我的login.html中实现了“登录按钮”。登录和注销都可以正常工作,但是如何在其他站点上检测到用户已登录?

function onSignIn(googleUser) {
    var profile = googleUser.getBasicProfile();
    console.log('ID: ' + profile.getId());
    console.log('Name: ' + profile.getName());
    console.log('Image URL: ' + profile.getImageUrl());
    console.log('Email: ' + profile.getEmail());

}
function signOut() {
  var auth2 = gapi.auth2.getAuthInstance();
  auth2.signOut().then(function () {
    window.location.href='login.html';
    console.log('User signed out.');
  });
}

0 个答案:

没有答案