how to set logging interceptor using OkHttpClient with time out for retrofit
Date : March 29 2020, 07:55 AM
wish helps you i basically want want use both of below features , Just add it there: HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient client = new OkHttpClient.Builder()
.addInterceptor(logging)
.connectTimeout(300, TimeUnit.SECONDS)
.readTimeout(300,TimeUnit.SECONDS)
.build();
|
Retrofit handling token expiration
Date : March 29 2020, 07:55 AM
it helps some times Retrofit is made to help YOU handle the requests you need. It doesn't handle token expiration. This means, that you need to handle that yourself. For example, in your request error handling, you can check for 401 error Unauthorized (this is usually the error a server sends when a token expires). When this occurs, hold the failed request and send another request for a new token. When the new request is successfully completed, you will have your token refreshed and you can retry the initial failed request with the newly fetched token.
|
Using Axios interceptor to stop requests and check for token expiration
Date : March 29 2020, 07:55 AM
will help you It might be that in your first callback function it needs to be returned as a Promise or for it to be declared async: axios.interceptors.request.use(async config => {
let accessToken = getAccessToken()
if (accessToken && user) {
config.headers['authorization'] = `Bearer ${accessToken}`
config.headers['cache-control'] = `no-cache`
const { exp } = jwtDecode(accessToken)
if (Date.now() > exp * 1000) {
await refreshAccessToken(); // wait for refresh
return config;
} else {
return config
}
}
}, function (error) {
return Promise.reject(error)
})
|
DocuSign: set expiration in JWT Token - always get access token with one hour expiration
Date : March 29 2020, 07:55 AM
With these it helps The maximum grant time for access tokens received via the DocuSign OAuth JWT Grant flow is 1 hour. The maximum grant time for access tokens received via the DocuSign OAuth Authorization Code Grant flow is 8 hours.
|
Retrofit logging interceptor exception
Date : March 29 2020, 07:55 AM
|