Token based authentication from xamarin

937
2
10-11-2021 01:12 AM
Riyasdsrc
New Contributor II

To implement token based authentication, there are sample to use the Authentication Manger and the user credentials used to login and generate the token. Once the token generated it automatically allow the server to enabled to access and those operations handled by ArcGIS NuGet. 

            TokenCredential userCredentials = await AuthenticationManager.Current.GenerateCredentialAsync
                                        (requestInfo.ServiceUri,
                                         e.Username,
                                         e.Password,
                                         requestInfo.GenerateTokenOptions);


My question is, since the token can be created for some amount of time, is there any other way to reuse the generated token instead of creating every time with the user credentials & AUTH Manager. 

0 Kudos
2 Replies
JoeHershman
MVP Regular Contributor

I assume you meant ArcGIS online not ArcGIS nuget.

If you use the challenge handler pattern, it will only request a new token when it is required.  Its a WPF sample but same in Xamarin

https://developers.arcgis.com/net/wpf/sample-code/arcgis-token-challenge/

 

Thanks,
-Joe
MichaelBranscomb
Esri Frequent Contributor

You could also take a look at the CredentialPersistence API: https://developers.arcgis.com/net/api-reference/api/android/Esri.ArcGISRuntime/Esri.ArcGISRuntime.Se...

For more info see this Dev Summit session and jump to 15:00 minutes: https://www.esri.com/videos/watch?videoid=HTqwqjvcL1k

0 Kudos