ExStoneOpenbank v0.1.2 ExStoneOpenbank.Authenticator.AuthHTTPMiddleware View Source
A Tesla Middleware that ensures we always have a valid access_token.
This middleware implementation has a retryable approach. It tries the call with the current token available. It might get a 401 at first and so, it calls for a refresh on the authenticator. This may block if the authenticator is trying to renew the token. When it gets a possibly new token it will retry the same call with the new token. In the case that it fails again, it will repeat this flow for 5 times (configured default limit of retries). If it fails after that, it will return the error.
This authentication flow is necessary to ensure we use the token the best way we can and avoid authenticating on every call.