我正在使用Google登录网站。 https://developers.google.com/identity/sign-in/web/
根据文档,在Yii::t()
函数下,我使用onSignIn(googleUser)
但显然这不是我将来可以使用的googleUser.getAuthResponse().id_token
撤销。如何从googleUser对象获取客户端的access_token
?
答案 0 :(得分:4)
经过几个小时的破解,我得到了Google开发人员的回答。
使用以下行。在true
函数中传递getAuthResponse
会返回access_token
和expiry
。这是推荐的解决方案。
googleUser.getAuthResponse(true).access_token;
答案 1 :(得分:2)
检查回叫中的googleUser
。你会发现Zi
属性。在该对象中,您还会发现access_token
和expire
次。
function onSignIn(googleUser) {
console.log(googleUser.Zi);
}