Power entry token refresh in oauth2?
I’m consuming the oauth2 package deal to login and keep authorization in an api. It really works completely with http requests. The shopper auto refreshes the entry token utilizing the refresh token if the entry token is expired. My logic refreshes each tokens if the refresh token will get close to the tip of lifespan. Completely no downside, all the things works completely.
Have recently added a websocket connection. It makes use of the entry token to create a connection. Provides subscriptions that additionally use entry tokens. Completely no downside both. So long as http requests no problemo.
However, I have to refresh the entry token to reauthorize the websocket connection close to the tip of the entry token’s life span. This must be carried out earlier than the present entry token expires. The recent entry token is then used to reauthorize the websocket connection.
Presently I strive to do that about one minute earlier than the entry token expires. I exploit the identical code snippet as is used to refresh each tokens if the refresh token will get close to expiration. This methodology doesn’t appear to work because the previous, close to expiration token is returned. Perhaps the entry token must be expired for this routine to work?
Is there a strategy to power tokenSource.Token() to refresh tokens earlier than an entry token has expired? Or does anybody have any various methodology to implement this use case? Can the token expiry be modified to control the tokenSource to run a refresh?