We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ab837ae commit 81e8ddcCopy full SHA for 81e8ddc
msal/token_cache.py
@@ -192,11 +192,12 @@ class SerializableTokenCache(TokenCache):
192
Depending on your need,
193
the following simple recipe for file-based persistence may be sufficient::
194
195
- import atexit, msal
+ import os, atexit, msal
196
cache = msal.SerializableTokenCache()
197
- cache.deserialize(open("my_cache.bin", "rb").read())
+ if os.path.exists("my_cache.bin"):
198
+ cache.deserialize(open("my_cache.bin", "r").read())
199
atexit.register(lambda:
- open("my_cache.bin", "wb").write(cache.serialize())
200
+ open("my_cache.bin", "w").write(cache.serialize())
201
# Hint: The following optional line persists only when state changed
202
if cache.has_state_changed else None
203
)
0 commit comments