【问题标题】:How to get refresh token for google plus in android?如何在android中获取google plus的刷新令牌?
【发布时间】: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-plus


【解决方案1】:

这个link 非常清楚地解释了获取令牌并为服务器端轮询引用令牌所需的 API。

你会收到这样的回复。

{
  "access_token" : "ya29.AHES6ZSuY8f6WFLswSv0HELP2J4cCvFSj-8GiZM0Pr6cgXU",
  "token_type" : "Bearer",
  "expires_in" : 3600,
  "refresh_token" : "1/551G1yXUqgkDGnkfFk6ZbjMLMDIMxo3JFc8lY8CAR-Q"
}

在跨平台场景中使用令牌时,您最好阅读此guide

【讨论】:

    猜你喜欢
    • 2014-07-08
    • 1970-01-01
    • 1970-01-01
    • 2014-06-10
    • 2018-02-27
    • 1970-01-01
    • 2014-04-18
    • 2012-02-15
    • 2016-05-11
    相关资源
    最近更新 更多