Friday, November 11, 2016

Google OAuth not returning refresh token

I'm not receiving the refresh token. The response in my case is:

{
 "access_token" : "ya29.sddsdsdsdsds_h9v_nF0IR7XcwDK8XFB2EbvtxmgvB-4oZ8oU",
"token_type" : "Bearer",
"expires_in" : 3600
}
 
 
The refresh_token is only provided on the first authorization from the user. Subsequent authorizations, such as the kind you make while testing an OAuth2 integration, will not return the refresh_token again. :)
  1. Go to your account security settings: https://www.google.com/settings/u/1/security.
  2. Click the Sign-in & Security -> Connected apps & Sites .
  3. Then click "MANAGE APPS".
  4. Click on your app and "Remove"
  5. The next OAuth2 request you make will return a refresh_token.
Alternatively, you can add the query parameter prompt=consent to the OAuth redirect (see Google's OAuth 2.0 for Web Server Applications page).
This will prompt the user to authorize the application again and will always return a refresh_token.

No comments:

Post a Comment