Open
Description
Why
Most of the apps use API requests and have a refresh token
mechanism to request new access tokens in case they expire. We don't have the setup for the initial TokenAuthenticator
yet, so we should add it to our templates.
The initial Authenticator needs to contain:
- max attempt/retry logic (normally set to 3).
- make use of
synchronized(this) {}
when executing the refresh token and rebuild the request to handle multiple authenticator calls at a time. - try/catch wrapping to catch errors during token refreshing. The default action in case an error has occurred.
Who Benefits?
Developers
who use this template to initialize their project with network requests.
I think this is essential because most of apps have API request and have refresh token mechanism. Having a standard setup would help us a lot in development and reduce mistakes.
Example of implementation: https://github.com/nimblehq/toyota-wallet-android/blob/main/data/src/main/java/co/omise/gcpf/service/authenticator/ApplicationRequestAuthenticator.kt