0
votes

I have use the code from this topic : Unable to get the subscription information from Google Play Android Developer API

I can get the refresh token from the uri

https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/androidpublisher&response_type=code&access_type=offline&redirect_uri=REDIRECT_URI&client_id=CLIENT_ID

I call getRefreshToken(token from URI) and the anwser is :

{
    "access_token" : "ya29.1.AADtN_XSr_9GwIybDh0fT5kt487DGYEed2sTzugp_MDOLEJAiMOTY3o17HwnvA7BIgP6",
    "token_type" : "Bearer",
    "expires_in" : 3407
}

With this acces token I can get information about my google android developper account.

The problem is the access token expires after 1 hour and I can't regenerate it. I try to call getAccessToken(token from uri) and the anwser is :

{
    "error" : "invalid_grant"
}

I use this code on a google app engine server in JAVA.

If someone recode thus methode with com.google.api.client.auth.oauth2 can be awesome.

1
What are you asking here? (Also, I think it's unadvisable you put your own access token here) - Ilan
It' not a valide token ^^. I'm asking , How to get a new acces token with the refresh token - Kingstone59

1 Answers

2
votes

Default first response when you get the refresh token is:

{ 
"access_token" : "****", 
"token_type" : "Bearer", 
"expires_in" : 3600,
"refresh_token" : "****" 
}

Every next response returns:

{ 
"access_token" : "****", 
"token_type" : "Bearer", 
"expires_in" : 3600,
}

You need delete oAuth from google account or use "approval_prompt=force" in request for force take refresh token.