Cache credentials after closing app

845
2
08-10-2018 09:49 AM
ChrisDougherty
New Contributor III

I'm developing a Xamarin.Forms app, and using AuthenticationManager.Current.GetCredentialAsync() to challenge the user for credentials to our Portal. We can then use ArcGISPortal.CreateAsync(uri, cred) to get the Portal instance and access to user content and data. My question is: Is there a way to cache the Credentials object or something similar? I don't want to have to prompt the user for credentials every time they open the app, when things like tokens can last for days. I've looked at locally storing the token itself, but that doesn't help get me an authenticated ArcGISPortal object.

0 Kudos
2 Replies
JenniferNery
Esri Regular Contributor

It looks like you can use AccountStore in Xamarin Forms.

You can use AddCredential to set credentials for your app but be sure each credential have their ServiceUri property also set so that Authentication Manager will know to use this credential for the given endpoint.

0 Kudos
ChrisDougherty
New Contributor III

Thank you for your quick reply. AccountStore does look like the right road to go down, but since this is an OAuth request using Esri's AuthenticationManager, I don't have access to the user's actual username and password. Instead I get back the Credential object, and I'm not sure how I'd store that into AccountStore as that seems to be mostly a key-value store. 

I did also check to make sure the credentials we're passing through AddCredential have their ServiceUri set, but it didn't help in persisting through different runs of the app. 

0 Kudos