token_cache Module

Classes

SerializableTokenCache

This serialization can be a starting point to implement your own persistence.

This class does NOT actually persist the cache on disk/db/etc.. Depending on your need, the following simple recipe for file-based persistence may be sufficient:


   import os, atexit, msal
   cache = msal.SerializableTokenCache()
   if os.path.exists("my_cache.bin"):
       cache.deserialize(open("my_cache.bin", "r").read())
   atexit.register(lambda:
       open("my_cache.bin", "w").write(cache.serialize())
       # Hint: The following optional line persists only when state changed
       if cache.has_state_changed else None
       )
   app = msal.ClientApplication(..., token_cache=cache)
   ...
TokenCache

This is considered as a base class containing minimal cache behavior.

Although it maintains tokens using unified schema across all MSAL libraries, this class does not serialize/persist them. See subclass SerializableTokenCache for details on serialization.

Functions

is_subdict_of

is_subdict_of(small, big)

Parameters

small
big