How to recover from a Spring Social ExpiredAuthorizationException

938 Views Asked by At

I am trying to implement Google Oauth2 with Spring Social and spring-social-google. Initial authentication works fine. However after some time the authentication expires and I am hit by

org.springframework.social.ExpiredAuthorizationException: The authorization has expired.

How can you recover from this exception? Is it possible to somehow refresh the authorization?

1

There are 1 best solutions below

4
On BEST ANSWER

Try to send additional access_type=offline paramter during authorization. It may looks something like this:

<form ...>
    .....
    <input type="hidden" name="access_type" value="offline"/>
</form>

Normally in this case authorization will be refreshed automatically for you. See this entry for more details.