0

I am calling a webservice in my Application which has authentication tokens that can expire. In case of token expiry, I need to refresh the token and retry the webservice. To do this, I felt spring retry might be the right candidate. But I have no idea how to inject this refresh token service in between my retries.

David John
  • 179
  • 1
  • 11
  • Related: [Call REST webservice using Spring Integration and Oauth](https://stackoverflow.com/q/36861053/476716) – OrangeDog Jun 19 '17 at 10:49

1 Answers1

1

Spring Retry is not what you want. That is for idempotent operations where you literally just try again.

Is this an OAuth token? Then you want Spring Security OAuth.

Even if not you want to do the same thing that Oauth2RestTemplate does: hook the token handling into the client.

OrangeDog
  • 36,653
  • 12
  • 122
  • 207
  • Thanks a lot for the response. Ok .. "idempotent operations"!!! The webservice has oauth tokens. We are currently using Spring Integration MessagingGateway to hit the webservice. Is there a way to inject Oauth functionality to these integration gateways? Please don't mind my noobness – David John Jun 19 '17 at 10:43
  • The `int-http:outbound-gateway` appears to have a `restTemplate` parameter. That's probably how you integrate them. – OrangeDog Jun 19 '17 at 10:48