2017-10-15 142 views
0

在我的Android Wear應用:Android Wear的OAuth2.0沒有收到刷新令牌

我打個電話,讓我的授權碼:

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」:「持票人「,」expires_in「:3574}

我在初始代碼請求中包含參數access_type = offline。爲什麼我沒有獲得刷新標記?我嘗試了OAuth2.0 Playground,並在開發者控制檯中將redirect_uri「https://developers.google.com/oauthplayground」添加到我的項目中,並且我可以在那裏接收它。有什麼區別,我該如何解決這個問題?提前致謝。

回答