OAuth2RestTemplate and handling of expired tokens

Viewed 598

We have been using Spring Oauth2 rest template and has been working well. Can someone please clarify on what the recommendations are for handling expired bearer tokens. The OAuth 2 spec states that the consumer should return 401 with error = invalid_token.

Is it expected that the Oauth2RestTemplate detect the invalid_token response and then request a fresh token from the auth server? Or should it be smart to know that the token is going to expire and request a new token beforehand?

Can some one kindly recommend the best practice? I think it is doing the former correctly, but wanted to know if there is any value in doing the latter.

0 Answers
Related