简体   繁体   English

如何从Android OAuth的刷新令牌获取access_token

[英]How can I get access_token from refresh token at android oAuth

I am developing small android app which fetch the google contacts with google contacts api. 我正在开发小型Android应用程序,该应用程序会使用Google联系人API获取Google联系人。

Now I am getting access_token and refresh_token from oAuth. 现在,我从oAuth获取access_token和refresh_token。 But at next launch user does not need google login again. 但在下次启动时,用户无需再次使用Google登录。 so I am going to get the access_token from refresh token. 所以我将从刷新令牌中获取access_token。

Can you let me know the best way to get access_token from refresh_token? 您能让我知道从refresh_token获取access_token的最佳方法吗?

Many thanks. 非常感谢。

I think access_type=offline suits for your usecase. 我认为access_type=offline适合您的用例。

If your application needs offline access to a Google API, then the request for an authorization code should include the access_type parameter, where the value of that parameter is offline. 如果您的应用程序需要脱机访问Google API,则授权码请求应包含access_type参数,该参数的值处于脱机状态。

This will return the refresh token the first time the user authorises the app. 这将在用户首次授权应用程序时返回刷新令牌。 Subsequent calls do not force you to re-approve the app (approval_prompt=force). 随后的调用不会强制您重新批准该应用程序(approval_prompt = force)。

You can refer to this page for more details: https://developers.google.com/accounts/docs/OAuth2WebServer#offline 您可以参考此页面以了解更多详细信息: https : //developers.google.com/accounts/docs/OAuth2WebServer#offline

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM