--

If you're using Okhttp you should consider using the Authenticator instead of this method. It will automatically refresh your access tokens without having to manually check the expiry and fetch new ones. The server can invalidate your tokens before they expire too. OkHttp's authenticator handles that too.

The other thing to remember is to give your refresh token client its own set of HTTP dispatchers (or parallel clients or whatever library you're using to call your web service). If you've got a lot of parallel API calls going on it's conceivable that you will run out of dispatchers within the "main" API and sit stuck while the refresh token API client waits for a free dispatcher.

--

--

Michael Ferguson
Michael Ferguson

Written by Michael Ferguson

Android software developer. Views and opinions expressed are my own and not that of my employer.

No responses yet