Authentication Google登录:检测授予身份验证的用户

Authentication Google登录:检测授予身份验证的用户,authentication,google-signin,google-api-js-client,Authentication,Google Signin,Google Api Js Client,我使用了谷歌提供的2个版本的基本谷歌sigin代码: 这段代码告诉我用户何时登录google 我现在需要的是,只有当用户单击google弹出窗口上的“允许”时才会调用的代码,google希望查看用户的个人资料,因此我可以检测用户何时单击该按钮。以下是我解决该问题的方法: function onSuccess(googleUser) { if (googleUser.getAuthResponse().hasOwnProperty("access_token")) { /* C

我使用了谷歌提供的2个版本的基本谷歌sigin代码:

这段代码告诉我用户何时登录google


我现在需要的是,只有当用户单击google弹出窗口上的“允许”时才会调用的代码,google希望查看用户的个人资料,因此我可以检测用户何时单击该按钮。

以下是我解决该问题的方法:

function onSuccess(googleUser) {
  if (googleUser.getAuthResponse().hasOwnProperty("access_token"))
      { /* CODE TO BE EXECUTED ONLY AFTER USER HAS ALLOWED ACCESS */ }
}