Closed amr-muhammad-anwar closed 1 month ago
Take a look at the "Authenticate with token" sample, here: https://github.com/Esri/arcgis-maps-sdk-flutter-samples/blob/21fc8cb39085566b854df13a8404722ac22762b8/lib/samples/authenticate_with_token/authenticate_with_token_sample.dart#L198-L208
It shows how to use handleArcGISAuthenticationChallenge
to respond to an authentication challenge. Then it shows how to use TokenCredential.createWithChallenge()
to create a credential, and then challenge.continueWithCredential(credential)
to complete the challenge.
The method 'OAuthUserConfiguration' isn't defined for the type '_AuthenticateWithOAuthSampleState'
can't import OAuthUserConfiguration at AuthenticateWithOAuthSample
import 'package:arcgis_maps/arcgis_maps.dart'; import 'package:arcgis_maps_sdk_flutter_samples/src/samples/setUp.dart';
@PaulAllanSturm
@PaulAllanSturm @jenmerritt
The method 'OAuthUserConfiguration' isn't defined for the type '_AuthenticateWithOAuthSampleState'. (Documentation) Try correcting the name to the name of an existing method, or defining a method named 'OAuthUserConfiguration'.
Ah yes, OAuthUserConfiguration was added in Beta 2. Authentication won't work with the current Beta 1 package. Beta 2 will be released in a week or two.
thank you
import com.arcgismaps.httpcore.authentication.ArcGISAuthenticationChallenge import com.arcgismaps.httpcore.authentication.ArcGISAuthenticationChallengeHandler import com.arcgismaps.httpcore.authentication.ArcGISAuthenticationChallengeResponse import com.arcgismaps.httpcore.authentication.ArcGISCredential
class AppAuthHandler ( val createCredential:suspend() ->Result
): ArcGISAuthenticationChallengeHandler {
override suspend fun handleArcGISAuthenticationChallenge(challenge: ArcGISAuthenticationChallenge):ArcGISAuthenticationChallengeResponse{
val result=createCredential()
return result.let{
if(it.isSuccess){
ArcGISAuthenticationChallengeResponse.ContinueWithCredential(it.getOrThrow())
}else{
ArcGISAuthenticationChallengeResponse.ContinueAndFailWithError(it.exceptionOrNull()!!)
}
}
}
}