Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/454.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 谷歌网站登录-如何获取令牌_Javascript_Html_Authentication_Google Authentication_Google Oauth - Fatal编程技术网

Javascript 谷歌网站登录-如何获取令牌

Javascript 谷歌网站登录-如何获取令牌,javascript,html,authentication,google-authentication,google-oauth,Javascript,Html,Authentication,Google Authentication,Google Oauth,我正在使用谷歌登录网站 根据文档,在函数onSignIn(googleUser)下,我使用googleUser.getAuthResponse().ID\u令牌获得ID\u令牌 但显然这不是我将来可以用来撤销的access\u令牌。如何从googleUser对象获取客户端的访问\u令牌?在回拨中检查googleUser。您将在其中找到Zi属性。在该对象中,您将发现访问\u令牌和过期时间 function onSignIn(googleUser) { console.log(googleU

我正在使用谷歌登录网站

根据文档,在函数
onSignIn(googleUser)
下,我使用
googleUser.getAuthResponse().ID\u令牌获得ID\u令牌


但显然这不是我将来可以用来撤销的
access\u令牌。如何从googleUser对象获取客户端的
访问\u令牌

在回拨中检查
googleUser
。您将在其中找到
Zi
属性。在该对象中,您将发现
访问\u令牌
过期
时间

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

经过几个小时的努力,我终于从一位谷歌开发者那里得到了答案

使用下面的行。在
getAuthResponse
函数中传递
true
将返回
access\u令牌
到期
。这是推荐的解决方案

googleUser.getAuthResponse(true).access_token;