Where to store tokens in a xamarin.form application

Just an update for anyone searching, as things have changed since this post was created. It is not advised to use the following any more:

Application.Current.Properties

To securely store things like access tokens etc you can use the Xamarin.Essentials SecureStorage static class.

Just add the Xamarin.Essentials nuget package if you don't already have it and use it like so:

using Xamarin.Essentials;
.
.
.

await SecureStorage.SetAsync("someKey", "someValue");

var myValue = await SecureStorage.GetAsync("someKey");

you also have the option to

SecureStorage.Remove("someKey");
//or 
SecureStorage.RemoveAll();

Refer this for more documentation


Forms has a built in Properties dictionary where you can store small bits of persistent data.

Application.Current.Properties ["token"] = myToken;

Token(s) being sensitive information, I would recommend storing them in a secure manner. Secure storage is available through Keychain services in iOS, and the KeyStore class in Android. Xamarin has a very good article on how to do that using Xamarin.Auth.

Other options available are:

  1. BlobCache.Secure in Akavache
  2. SecureStorage
  3. Secure storage in XLabs