spring-social / spring-social-google

Spring Social extension with connection support and an API binding for Google
https://spring-social-google.github.io/spring-social-google/
Apache License 2.0
214 stars 164 forks source link

Asking for refresh_token and dealing with fetching new access_token when it expired #91

Open vwiencek opened 8 years ago

vwiencek commented 8 years ago

I'm using spring social google to get access to users's email informations. As i'm performing background operations, I need a way to refresh the token when it expires without asking the user to authorize the application again.

I figured out that we could get a refresh token by adding the following parameters to the OAuth2Parameters object

params.set("access_type", "offline");
params.set("approval_prompt","force");

This will force google OAuth mechanism to provide a refresh_token. Then when the access_token expires, we can exchange the refresh_token for a new access_token.

thx

tinmegali commented 7 years ago

Hello @vwiencek, did you manage to find a work around this issue? I investigated the source code, however, I was incapable of finding a way to configure the OAuth2Parameters using the spring-social-google as it is? Am I missing something? tks