【发布时间】:2015-07-14 18:01:26
【问题描述】:
我正在使用以下代码来获取 google plus 的访问令牌。有没有办法获取刷新令牌,以便我可以从 Web 服务器离线访问 google API。
String accountName = params[0];
String scopes = "oauth2:profile email";
String token = null;
try {
token = GoogleAuthUtil.getToken(getApplicationContext(), accountName, scopes);
} catch (IOException e) {
Log.e(TAG, e.getMessage());
} catch (UserRecoverableAuthException e) {
startActivityForResult(e.getIntent(), REQ_SIGN_IN_REQUIRED);
} catch (GoogleAuthException e) {
Log.e(TAG, e.getMessage());
}
【问题讨论】:
-
您为什么要离线访问 Android 应用程序?根据 Google 的 API 文档,离线访问适用于 Web 应用程序。好奇这里的用例是什么。 developers.google.com/identity/protocols/…
-
@thedarkpassenger IMO,您可以在以下问题stackoverflow.com/questions/33998335/…(
With a sucessful response, you will have the following info in logcat:)阅读我的回答
标签: android google-plus