/// <summary> /// Deserializes the token cache from a serialization blob in the unified cache format /// </summary> /// <param name="tokenCache">Token cache to deserialize (to fill-in from the state)</param> /// <param name="unifiedState">Array of bytes containing serialized Msal cache data</param> /// <remarks> /// <paramref name="unifiedState"/>Is a Json blob containing access tokens, refresh tokens, id tokens and accounts information. /// </remarks> public static void Deserialize(this TokenCache tokenCache, byte[] unifiedState) { GuardOnMobilePlatforms(); lock (tokenCache.LockObject) { RequestContext requestContext = new RequestContext(null, new MsalLogger(Guid.Empty, null)); TokenCacheSerializeHelper.DeserializeUnifiedCache(tokenCache.TokenCacheAccessor, unifiedState, requestContext); } }
/// <summary> /// Serializes the entire token cache, in the unified cache format only /// </summary> /// <param name="tokenCache">Token cache to serialize</param> /// <returns>array of bytes containing the serialized unified cache</returns> public static byte[] Serialize(this TokenCache tokenCache) { GuardOnMobilePlatforms(); // reads the underlying in-memory dictionary and dumps out the content as a JSON lock (tokenCache.LockObject) { return(TokenCacheSerializeHelper.SerializeUnifiedCache(tokenCache.TokenCacheAccessor)); } }