Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Mention import for an inline sample
  • Loading branch information
rayluo authored Mar 6, 2019
commit 108258e86db2ece9d9f8db2b6d6fd95ab07b02d3
6 changes: 3 additions & 3 deletions msal/token_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,15 @@ class SerializableTokenCache(TokenCache):
Depending on your need,
the following simple recipe for file-based persistence may be sufficient::

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

:var bool has_state_changed:
Expand Down