Forum Xamarin Xamarin.Android

Azure saving of cache tokens does not work

JoergenStorlieJoergenStorlie US ✭✭
edited November 2016 in Xamarin.Android

It is an bug in Xamarin Android that causes the cache tokens not to save.

TokenCachePlugin.cs: Failed to save cache: System.Runtime.Serialization.InvalidDataContractException: No set method for property 'OffsetMinutes' in type 'System.Runtime.Serialization.DateTimeOffsetAdapter'.

This causes the login prompt to appear every time the user uses the app.

This workaround fixed the issue:

I think this due to too aggressive Xamarin.Android linking. This still occurs with Xamarin's cycle 7 release. We faced the same issue and for now have worked around it by adding

in the Android csproj file for the Release configuration.

Waiting for a Xamarin update with a proper fix for this... See

Here is the code that did not work:

AuthenticationContext authContext = new AuthenticationContext(commonAuthority);

            if (logout == true)

            if (authContext.TokenCache.ReadItems().Count() > 0)
                authContext = new AuthenticationContext(authContext.TokenCache.ReadItems().First().Authority);

            authResult = await authContext.AcquireTokenAsync(graphResourceUri, clientId, returnUri, parent);
            ExternalUniqueId = authResult.UserInfo.UniqueId;
Sign In or Register to comment.