2

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?

Kees de Kooter
  • 7,078
  • 5
  • 38
  • 45

1 Answers1

1

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.

Maksym Demidas
  • 7,707
  • 1
  • 29
  • 36
  • I am posting this parameter to the spring social controller. Probably that controller is not passing it on to google. – Kees de Kooter May 03 '13 at 12:36
  • This pull request supports that assumption: https://github.com/GabiAxel/spring-social-google/pull/23 – Kees de Kooter May 03 '13 at 13:24
  • I forked the spring-social-google incorporating the pull request. Now I am able to refresh the connection! Accepting the answer because it put me on the right track. – Kees de Kooter May 04 '13 at 18:10
  • Strange. I am sure it worked for me out of the box in my previous project (I mean that this additional parameter was send from the beginning and we did not experience any issues with expiration). Unfortunately now I do not have access to codebase to be able check it. Kees, glad to know that it works for you now. – Maksym Demidas May 06 '13 at 08:22