-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] msal.TokenCache is not picklable. #648
Comments
Thanks for the suggestion. We will give it some thoughts and see what we can do. UPDATE: More info was described in the internal work item. |
The customer ask seems to be for confidential client, not for public client? |
Pickling is a Python terminology and implementation of object serialization.
That original customer happened to be using a confidential client, but the temptation to pickle may also present for a public client app.
I am still self-debating whether this feature request is desirable.
|
Yes. There are some objects that are not picklable. It is by design. e.g. our transport. If only partial of the object that we don't want to pickle, we can remove them when pickling and re-create them when unpickling. (This is what we have today for transport in the pipeline). Please evaluate the object, if there is nothing other than unsafe-to-pickle information stored in the object, we are ok if is not picklable. |
In that case, we are not sure whether the TokenCache object shall be picklable, based on the Since Azure Identity already made some change on choosing what objects to be picklable, what if Azure Identity's Credentials simply choose to recreate a new empty token cache when being unpickled? @xiangyan99 |
MSAL Python has long been supporting "serializing token cache to json", which is more interchangeable across different languages (thus becomes the battle-tested foundation of token cache sharing across MSALs in .Net/Java/Python); also, I believe json is more performant than pickle. I suppose you can either:
In either case, the caveat in my earlier comment above still stands. It is OK to save a token cache and reload it later, i.e. sequentially. But it is not meant to be shared among multiple processes concurrently. |
MSAL client type
Public
Problem Statement
This is from a customer request: Azure/azure-sdk-for-python#21996
If possible, we should have everything pickable.
Proposed solution
No response
The text was updated successfully, but these errors were encountered: