The Authgear Android SDK provides an optional Okhttp interceptor which handles everything from refreshing the access token to putting the access token in the header.
Get the Extension
The extension is included in the SDK. Please refer to the above section for getting the SDK.
Usage
Configure OkHttpClient to use AuthgearInterceptor as follows:
1
Authgear authgear =// Obtain the authgear instance.
2
OKHttpClient client =newOkHttpClient.Builder()
3
.addInterceptor(AuthgearInterceptor(authgear))
4
.build()
Copied!
The client would then include the access token in every request and refresh the access token when necessary before the requests.