Reputation: 41
I cannot get a refresh token for Google Play Authorization.
I'm following the instructions in the Google Play Android Developer API Authorization page. I created an OAuth 2.0 client ID. I successfully got a client ID. I put all the information in the URI to get a refresh token, I send the request, I'm prompted for "Allow access". When I click "Allow Access" I get an Unable to connect error. This is my URI:
Upvotes: 4
Views: 1856
Reputation: 61
When you create a "web" type client ID and call the /o/oauth2/auth service the redirect URI will be tried by your user agent (/browser). If it's fake like the one in your example (which is the default) then the user agent will of course fail. The authorization code will still be a parameter part of the failing URL but it may not be obvious.
With the authorization code in hand you then need to call the /o/oauth2/token service with a correctly fielded POST. I'm hesitant to point you to a particular Google instruction page since they can be notoriously incomplete, contradictory and outdated, but this one is a reasonable overview of the entire process https://developers.google.com/accounts/docs/OAuth2WebServer.
One thing to keep in mind is that the very first successful call to /o/oauth2/token for a given client ID will return the elusive refresh token but then it will not be returned again unless you retry the /o/oauth2/auth service providing the URL parameter approval_prompt=force. That bit of info is your reward for reading this far and will save you hours of pointless frustration.
Upvotes: 2
Reputation: 41
The unable to connect error contains a "code" parameter value . That value should be used as the "code" parameter value in the POST request to https://accounts.google.com/o/oauth2/token.
Upvotes: 0