I have a micro service that is using micronaut-security's oauth2 cliient-credentials flow to obtain an access token and propagate the same to a resourceClient in the header.
I want to know if there is a way to get a new access token in the client-credentials flow when the existing token is revoked for some reason and the resourceClient returns 401 Unauthorised response.
I've verified that if I call the resourceClient concurrently with multiple requests the access token remains the same and new access token is only fetched after the token expires.
Ive looked through the code in AbstractClientCredentialsClient on how it requests for a token either from the cache or from the auth server based on some criteria.
Does any one know. how I can achieve requesting new tokens on 401 responses from the resource client please, any examples would be great. micronaut version 3.9.3