-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
InteractiveBrowserCredential() never caches; each run forces user to interact with browser #9744
Comments
Integrating Azure CLI authentication into The identity signed in to the Azure Portal is available to |
OK, its good to know help is on the way. Thanks for being so responsive to these issues! Looking forward to trying out your progress... |
@chlowell, is there a quick-fix I can add to my code to cache the credentials while I am waiting for the official fix from you? Thanks... |
I'm afraid there isn't a quick fix. We don't have a cache ready to bolt on, and |
@chlowell , I attempted to do it myself with keyring. Did not succeed (as the mentioned issue shows). Are you planning to do the same thing that is done in azure CLI (az login) |
I just added a placeholder for my project (XT), while awaiting the official solution from your team. My project now runs a background process to hold the cached info I get upon the first authentication. How does the azure CLI does their creds caching? |
In azure-identity 1.4.0b3, released today, from azure.identity import InteractiveBrowserCredential
# this keyword argument enables caching to disk,
# currently only on Windows (Linux and macOS support coming soon)
credential = InteractiveBrowserCredential(enable_persistent_cache=True)
# call 'authenticate' to open a browser for the user to sign in...
record = credential.authenticate()
# ...or let a service client authenticate as needed, and retrieve the record later
record = credential.authentication_record
# the returned record contains no secrets, and serializes to JSON
record_json = record.serialize()
with open(RECORD_PATH, 'w') as f:
f.write(record_json) In a subsequent execution you can initialize the credential with the deserialized record, enabling it to use information cached previously: from azure.identity import AuthenticationRecord, InteractiveBrowserCredential
with open(RECORD_PATH, 'r') as f:
record_json = f.read()
deserialized_record = AuthenticationRecord.deserialize(record_json)
credential = InteractiveBrowserCredential(
authentication_record=deserialized_record,
enable_persistent_cache=True
) Please open an issue if you encounter any problems using the new API. We'll add persistent caching on Linux and macOS in a future release (that work is tracked by #11134). |
azure-identity==1.2.0
azure-keyvault==4.0.0
Describe the bug
I am integrating the use of "InteractiveBrowserCredential()" into a command line app that needs to read some secrets from keyvault on every run. Each time the app is run, focus is shifted to the browser and user is forced to interact to select a login identity.
I expected that the user would only have to deal with this authentication UI occassionally (once a week?), but it happens every single run. How can I tell the authentication code to cache the credentials? Even better, how can I share the cached credentials of the Azure Portal website or the Azure CLI?
Thanks...
The text was updated successfully, but these errors were encountered: