Esri / arcgis-maps-sdk-flutter-samples

Sample code for ArcGIS Maps SDK for Flutter
Apache License 2.0
11 stars 5 forks source link

can do it with flutter ? #104

Closed amr-muhammad-anwar closed 1 month ago

amr-muhammad-anwar commented 1 month ago

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()!!) } } } }

PaulAllanSturm commented 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.

amr-muhammad-anwar commented 1 month ago

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';

amr-muhammad-anwar commented 1 month ago
Screenshot 2024-08-01 at 9 26 10 AM

@PaulAllanSturm

amr-muhammad-anwar commented 1 month ago
Screenshot 2024-08-01 at 2 58 47 PM

@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'.

PaulAllanSturm commented 1 month ago

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.

amr-muhammad-anwar commented 1 month ago

thank you