【问题标题】:Android Wear OAuth2.0 Not receiving Refresh TokenAndroid Wear OAuth2.0 未收到刷新令牌
【发布时间】:2018-03-26 20:50:35
【问题描述】:

在我的 Android Wear 应用中:

我打电话来获取我的授权码:

https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/books&access_type=offline&redirect_uri=https://www.android.com/wear/3p_auth/com.apps.greyrobe.wordrunner&response_type=code&client_id=[MY_CLIENT_ID]

然后我在手机上授权该应用程序。我进行 POST 调用以获取我的令牌(访问和刷新):

https://www.googleapis.com/oauth2/v3/token?code=[MY_CODE]&client_id=[MY_CLIENT_ID]&client_secret=[MY_CLIENT_SECRET]&redirect_uri=https://www.android.com/wear/3p_auth/com.apps.greyrobe.wordrunner&grant_type=authorization_code

然后我收到回复:

{ "access_token": "[MY_ACCESS_TOKEN]", "token_type": "Bearer", "expires_in": 3574}

我在初始代码请求中包含了参数 access_type=offline。为什么我没有得到刷新令牌?我在 OAuth2.0 Playground 中进行了尝试,并将 redirect_uri "https://developers.google.com/oauthplayground" 添加到开发人员控制台中的项目中,我可以在那里接收它。有什么区别,我该如何解决?提前致谢。

【问题讨论】:

    标签: android oauth-2.0 google-oauth wear-os refresh-token


    【解决方案1】:

    分辨率

    转到https://myaccount.google.com/permissions 并从我的帐户中删除了我的应用程序的权限。再次尝试请求,我收到了刷新令牌。

    【讨论】:

      猜你喜欢
      • 2014-10-28
      • 2012-06-05
      • 2017-01-11
      • 2016-09-13
      • 2021-05-13
      • 1970-01-01
      • 1970-01-01
      • 2018-03-11
      • 1970-01-01
      相关资源
      最近更新 更多