TokenCache.SerializeMsalV2 Method


Serializes parts of the token cache to the MSAL.NET 2.x unified cache format. If you need to maintain SSO between an application using ADAL 3.x or later and MSAL 2.x, use both SerializeAdalV3()/DeserializeAdalV3(Byte[]) and SerializeMsalV2()/DeserializeMsalV2(Byte[]).

public byte[] SerializeMsalV2 ();
member this.SerializeMsalV2 : unit -> byte[]
Public Function SerializeMsalV2 () As Byte()



Byte stream representation of the cache


An application using ADAL should not rely exclusively on SerializeMsal* / DeserializeMsal* because access tokens and ID tokens will be lost, as they are not compatible between ADAL and MSAL. This will cause ADAL to contact AAD for an access token on every AcquireTokenSilent call, introducing seconds of delay into your app.

Applies to