Reputation: 1028
in my C# application, I am trying to get aouth2 access and refresh tokens:
https://developers.google.com/accounts/docs/OAuth2InstalledApp
On the phase: Handling the Response, When I make the call I am supposed to get something like:
{
"access_token":"1/fFAGRNJru1FTz70BzhT3Zg",
"expires_in":3920,
"token_type":"Bearer",
"refresh_token":"1/xEoDL4iW3cxlI7yDbSRFYNG01kVKM2C-259HOF2aQbI"
}
but I get
{
"access_token":"1/fFAGRNJru1FTz70BzhT3Zg",
"expires_in":3920,
"token_type":"Bearer",
}
Thus: refresh_token is missing. I debugged and I am sure I hit the api method: FetchAccessAndRefreshTokens but I have no refresh_token.
PS: I am using 201306 API
Any ideas?
Upvotes: 0
Views: 643
Reputation: 1028
In the API, within OAuth2ProviderForApplications.cs file, in GetAuthorizationUrl() method, on line 100 if you add &approval_prompt=force to the string:
return string.Format("{0}?scope={1}&state={2}&redirect_uri={3}&response_type={4}&" + "client_id={5}&access_type={6}&approval_prompt=force"
it works. But this is a horrible workaround plus it might create apache license issues.
How found: in google oauth2 playground (https://developers.google.com/oauthplayground/) this parameter (approval_prompt=force) is set and if you omit it, it does not give refresh token.
Upvotes: 1