网站的Google登录-如何获取令牌

4
我正在使用Google网站登录。https://developers.google.com/identity/sign-in/web/ 根据文档,在函数onSignIn(googleUser)下,我使用googleUser.getAuthResponse().id_token获取ID_Token。
但显然这不是我可以在将来用来撤销的access_token。如何从googleUser对象客户端获取access_token
2个回答

4

经过数小时的挣扎,我终于得到了一位Google开发者的答案。

使用以下代码行。在getAuthResponse函数中传递true将返回access_tokenexpiry。这是推荐的解决方案。

googleUser.getAuthResponse(true).access_token;

1

在回调函数中检查googleUser。您会在其中找到Zi属性,在该对象中,您还将找到access_tokenexpire时间。

function onSignIn(googleUser) {
    console.log(googleUser.Zi);
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接