问题描述
我用 GoogleAuthUtil
在谷歌播放服务
在Android上。调用 GoogleAuthUtil.getToken(背景下,用户名,范围)
之后,我得到了这样一个道理:
这是一个的access_token,可以在呼叫谷歌API来使用。然后,我怎样才能得到一个刷新令牌刷新此的access_token,因为我也用的和在我的Android项目,我想用这两个库维护/管理的access_token
,刷新标记
和 expires_in
值。 (当使用谷歌OAuth的Java库,在 TokenResponse
,它返回包含的access_token
,刷新令牌
和 expires_in
)
先谢谢了。
您不能直接使用获得refreshToken GoogleAuthUtil.getToken()
,但如果你调用为gettoken()
每次你得到一个401错误的时间,如果需要的话GoogleAuthUtil将返回一个新的有效令牌。
I'm using GoogleAuthUtil
in Google Play Services
on Android. After calling GoogleAuthUtil.getToken(context, userName, scope)
, I got a token like this:
ya29.wQBWztab5kcgMLcMbAI0LwFzHC_DPrxauSWbX4P6KOnBEOgjcm9V7OI9AFr6JGxDY54gP00RemzzgML56_gWRHn8Q5jK16BLY-0y83Gc5vfe3xN-QpyM4d7z
This is an access_token, which can be used in calling Google Apis. Then, how can I get a refresh token to refresh this access_token, because I also use Google oauth java library and YouTube Java Library in my Android project, I want to use these two libraries to maintain/manage the access_token
, refresh token
and expires_in
values. (When using Google oauth java library, the TokenResponse
it returned contains access_token
, refresh token
and expires_in
)
Thanks in advance.
You cannot directly get a refreshToken using GoogleAuthUtil.getToken()
but if you call getToken()
each time you get a 401 error, GoogleAuthUtil will return you a new valid token if needed.
这篇关于如何使用GoogleAuthUtil时候才能refreshToken的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!