Select to view content in your preferred language

Handle token expiry in AuthenticationChallengeHandler

327
0
07-27-2023 05:57 AM
KrithikaLakshmi
New Contributor

When authenticating using Oauth in Android using arcgis maps sdk (kotlin) , we have defined the authenticationchallegehandler to handle oauthcredential challenge like below. 

 

ArcGISAuthenticationChallengeHandler { challenge: ArcGISAuthenticationChallenge ->
val oAuthConfiguration = getOAuthConfiguration()
if (oAuthConfiguration != null && oAuthConfiguration.canBeUsedForUrl(challenge.requestUrl)) {
val oAuthUserCredential =
OAuthUserCredential.create(oAuthConfiguration) { oAuthUserSignIn ->
loginViewModel?.promptForOAuthUserSignIn(oAuthUserSignIn)
}.getOrThrow()

ArcGISEnvironment.authenticationManager.arcGISCredentialStore.add(
oAuthUserCredential
)
ArcGISAuthenticationChallengeResponse.ContinueWithCredential(
oAuthUserCredential
)
}
}

 

In this case, the user is shown the prompt to signin , in case the user is in the LoginActivity. How do we handle token expiry incase we are in a different activity ? How will we get the token expiry message? Any sample would be much appreciated.

0 Replies