question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getting crash in crashlytics "Fatal Exception: java.lang.IllegalStateException No authorization configuration available for refresh request net.openid.appauth.AuthState.createTokenRefreshRequest"

See original GitHub issue
Fatal Exception: java.lang.IllegalStateException: **No authorization configuration available for refresh request**
       at net.openid.appauth.AuthState.createTokenRefreshRequest(AuthState.java:615)
       at net.openid.appauth.AuthState.createTokenRefreshRequest(AuthState.java:601)
       at com.repository.LoginRepository$performRefreshTokenRequest$1.invokeSuspend(LoginRepository.java:66)
       at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(BaseContinuationImpl.java:33)
       at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.java:106)
       at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.java:571)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.java:738)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.java:678)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.java:665)

I am updating AuthorizationResponse also once receiving response, but getting this crash on refreshing token. Thing is it is not happening on all devices.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
JohannesTeichertcommented, Apr 27, 2021

I just stumbled upon this thread and was about to ask for help because I had the same exception, looking once more over my own code I realized that I did not update my authState with the AuthorizationResponse.

for me it works now like that:

after logging in the intent provides me with an AuthorizationResponse or AuthorizationException val authorizationResponse = AuthorizationResponse.fromIntent(data) val authorizationException = AuthorizationException.fromIntent(data)

update authState with response and exception authState?.update(authorizationResponse, authorizationException)

then I exchange the authcode for the actual tokens: authService.performTokenRequest(authorizationResponse.createTokenExchangeRequest()) { tokenResponse, exception -> authState.update(tokenResponse, exception) //do something with tokens or persist them, e.g.: authState.accessToken

then when I come back to try to cal createTokenRefreshRequest the lastAuthorizationResponse is not null anymore and the refresh works perfectly.

val tokenRefreshRequest = authState.createTokenRefreshRequest() authService.performTokenRequest(tokenRefreshRequest) { response, exception -> //again dont forget to update authstate authState.update(response, exception) //do something with tokens or persist them, e.g.: authState.accessToken

maybe that helps you as well

0reactions
Votocommented, Aug 31, 2022

We ran into this issue too. The challenge and from my opinion wrong behaviour is that you get this error only once per app session. We get this error from AuthState here

 @NonNull
    public TokenRequest createTokenRefreshRequest(
            @NonNull Map<String, String> additionalParameters) {
        if (mRefreshToken == null) {
            throw new IllegalStateException("No refresh token available for refresh request");
        }
        if (mLastAuthorizationResponse == null) {
            throw new IllegalStateException(
                    "No authorization configuration available for refresh request"); // <--- origin of exception line 636
        }

Throwing this error should also clear mPendingActions as the last action was canceled due to error. Because AuthState did not clear it each further request end here silently in performActionWithFreshTokens():

 synchronized (mPendingActionsSyncObject) {
            //if a token request is currently executing, queue the actions instead
            if (mPendingActions != null) { // <--- game over 
                mPendingActions.add(action);
                return;
            }

We actually solved our issue by a workaround. Our implementation uses a non-standard one-time-password for a seamless login after a user registers a new account. So we feed the AuthStateManager with a fake AuthorizationResponse

val authorizationResponse = AuthorizationResponse
                .Builder(authRequest)
                .setAccessToken(accessTokenResponse.access_token)
                .build()
            authStateManager.updateAfterAuthorization(authorizationResponse, null) // <-- feed the response
            authStateManager.rewriteUpdatedAuthState()
Read more comments on GitHub >

github_iconTop Results From Across the Web

Firebase Crashlytics crashes not being reported to the ...
When you open the Firebase Crashlytics page, it defaults to applying the 'Event type = "Crashes"' filter. Unhandled exceptions in Flutter ...
Read more >
How to solve java.lang.illegalstateexception in firebase ...
on clicking on the login button the app crashes and shows the following error message in the logcat java.lang.IllegalStateException: Not ...
Read more >
java.lang.Error" firebase crashlityic Log - Unity Forum
When I check the error logs on crashlytic,Bug some logs always like this: Caused by java.lang.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found