-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Enable persistent cache for user credentials on Linux and macOS #11134
Comments
This is available now in azure-identity 1.4.0b4. For example: from azure.identity import InteractiveBrowserCredential
# opting in to persistent caching
credential = InteractiveBrowserCredential(enable_persistent_cache=True)
# forgoing encryption when it isn't possible
credential = InteractiveBrowserCredential(
enable_persistent_cache=True, allow_unencrypted_cache=True
) |
Was this rolled back? patch notes indicates that it would be fixed in 1.5.0b1 but as of 1.5.0b2 it has not:
Is there a plan to reintroduce these? |
I believe #13070 restored that API for 1.5.0b1, and it's present in 1.5.0b2 as well. What's still missing? |
Hi, enable_persistent_cache=True does not seem to be working, I tried to use it in 1.5.0b2 and 1.5.0 on a mac device, and every time I am executing my code I get redirected to the web interface to approve my login. |
The API we're discussing here isn't in 1.5.0. We removed it from the stable release because we're redesigning it in light of new requirements. In the meantime this API is available in 1.5.0b2, and I expect it to work on a mac. Can you add a code example of what your application is doing? There's a bit more to it than # if your application hasn't authenticated a user yet, create a credential
# and call authenticate() to get an AuthenticationRecord
credential = InteractiveBrowserCredential(enable_persistent_cache=True)
record = credential.authenticate()
# serialize the record and store it however you like (it contains no secrets)
serialized_record = record.serialize()
# on subsequent runs, initialize a credential with the record
record = AuthenticationRecord.deserialize(serialized_record)
credential = InteractiveBrowserCredential(enable_persistent_cache=True, authentication_record=record) |
Thanks for the answer |
All tokens have expiration times set by Azure AD. Do you want to see this time, or to set a different one? |
Thanks for the answer. and then save it for later use? |
There's no need to set a token's expiration time. It wouldn't be effective (Azure AD determines the value) and credential classes handle caching tokens and replacing expired ones. You need the record because the cache may contain tokens for an arbitrary number of identities. The record is the key that tells the credential which cached tokens to use. |
so why do I need to use enable_persistent_cache=True, If I need to save the record somewhere and then receive it on the next run I would think that the following code should work (without enable_persistent_cache)
|
I see what you mean: |
Azure/azure-sdk-for-java#9188 has design details.
allow_unencrypted_cache
)The text was updated successfully, but these errors were encountered: