AppAuth-Android icon indicating copy to clipboard operation
AppAuth-Android copied to clipboard

No auth configuration available for refresh token

Open GiampA opened this issue 7 years ago • 6 comments

When i use the method performActionWithFreshTokens after the auth flow completion, and after the access_token is expired, I receive:

java.lang.IllegalStateException: No authorization configuration available for refresh request

What could be gone wrong? Parsing the response? I've saved the authState json previously, but I don't see any lastAuthorizationResponse key...

GiampA avatar Nov 07 '18 20:11 GiampA

Having the same issue, is this solved?

MytTantely avatar May 06 '19 20:05 MytTantely

I am not sure if this is the right solution, but this may help.

final AuthorizationResponse response = new AuthorizationResponse.Builder(authRequest)
                        .fromUri(uri)
                        .build();

authState.update(authorizationResponse, null);

ghost avatar May 24 '19 14:05 ghost

prior to saving your authState json, ensure you have updated the authState with an authenticationResponse and also with tokenResponse

// this is following the activity result
authState.update(authorizationResponse, ex) 

 // this comes following authService.performTokenRequest(request)
authState.update(tokenResponse, ex)

// so add a breakpoint, when you get here and see if your authState has both responses 
yourStoringFunctionality( authState.jsonSerializeString() )

// now when you need to refresh, first time just check if everything is in sync with the responses stored
val lastState = AuthState.jsonDeserialize(authStateJson)
lastState.performActionWithRefreshTokens( authService, clientSecretIfApplies, handler )

after your handler gets new accessToken, and idToken, your authState is automatically updated with those tokens, and there is no need to invoke update method again. Now you need to store it such as done above yourStoringFunctionality( authState.jsonSerializeString() ).

I have to say that the documentation is not very extended in how to do this

juanmendez avatar Feb 07 '20 19:02 juanmendez

This is quite helpful, if you see no refresh-token being provided either the first time tokens are generated or when they are refreshed, make sure to include offline_access to your scope This is the way it worked for me.

juanmendez avatar Feb 11 '20 17:02 juanmendez

I was missing offlline_access from my scope and adding that solved this for me as well.

MKevin3 avatar Sep 19 '20 18:09 MKevin3

This is quite helpful, if you see no refresh-token being provided either the first time tokens are generated or when they are refreshed, make sure to include offline_access to your scope This is the way it worked for me.

are you talking about setting like this for AuthorizationRequest Builder? .setScope("offline_access")

kishansolankiOpenxcell avatar Nov 12 '20 05:11 kishansolankiOpenxcell