CredentialsManagerException: An error occurred while trying to use the Refresh Token to renew the Credentials

I have this problem and it happens occasionally while user has Internet connection and connection timeout set to 20 seconds.
library version 1.26.1

The code where crash occurs

class Auth0Authority [@Inject](https://github.com/Inject) constructor(
private val auth0Service: Auth0Service
 ) : Interceptor {

 override fun intercept(chain: Interceptor.Chain): Response {
try {
    val original = chain.request()
    val credentials = auth0Service.getCredentials().blockingGet()
    val request = original.newBuilder().  
                 .header("Authorization", "${credentials.type} ${credentials.accessToken}")
                .header("Timezone-Offset", getTimezoneOffsetSeconds())
               .build()
        return chain.proceed(request)
} catch (ex: CredentialsManagerException) {
      //crash here
       Timber.e(ex)
       throw IOException(ex)
      }
    }
 }

here is stack trace

2020-10-28 10:04:08.691 32319-908E/Auth0Authority: com.auth0.android.authentication.storage.CredentialsManagerException: An error occurred while trying to use the Refresh Token to renew the Credentials.
at com.auth0.android.authentication.storage.CredentialsManager$1.onFailure(CredentialsManager.java:126)
at com.auth0.android.authentication.storage.CredentialsManager$1.onFailure(CredentialsManager.java:114)
at com.auth0.android.request.internal.BaseRequest.postOnFailure(BaseRequest.java:98)
at com.auth0.android.request.internal.BaseRequest.onFailure(BaseRequest.java:152)
2020-10-22 11:04:28.129 15782-15782/W/ErrorExtentionsKt: java.net.SocketTimeoutException: timeout
at okhttp3.internal.http2.Http2Stream$StreamTimeout.newTimeoutException(Http2Stream.java:656)
at okhttp3.internal.http2.Http2Stream$StreamTimeout.exitAndThrowIfTimedOut(Http2Stream.java:664)
at okhttp3.internal.http2.Http2Stream.takeHeaders(Http2Stream.java:153)
at okhttp3.internal.http2.Http2Codec.readResponseHeaders(Http2Codec.java:131)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:212)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at network.RequestLoggingInterceptor.intercept(RequestLoggingInterceptor.kt:19)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at network.Auth0Authority.intercept(Auth0Authority.kt:24)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:254)
at okhttp3.RealCall.execute(RealCall.java:92)
at com.google.firebase.perf.network.FirebasePerfOkHttpClient.execute(com.google.firebase:firebase-perf@@18.0.1:5)
at retrofit2.OkHttpCall.execute(OkHttpCall.java:180)
at retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:42)
at io.reactivex.Observable.subscribe(Observable.java:10955)
at retrofit2.adapter.rxjava2.BodyObservable.subscribeActual(BodyObservable.java:34)
at io.reactivex.Observable.subscribe(Observable.java:10955)
at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeTask.run(ObservableSubscribeOn.java:96)
at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:452)
at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:61)
at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:52)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)

Hi @sara1 - welcome to the Auth0 Community!

It seems like the request is timing out here. Would there be a possibility that the user has a slow connection or a lot of latency?

Thanks!

1 Like

Thanks for the update and quick reply. I’ll be sure to keep an eye on this thread. Looking for the same issue. Bumped into your thread. Thanks for creating it. Looking forward for solution MCDVOICE

1 Like