-
Notifications
You must be signed in to change notification settings - Fork 3.3k
SharedTokenCacheCredential with Custom TokenCachePersistenceOptions Does Not Persist #26982
Copy link
Copy link
Closed
Labels
Azure.IdentityClientThis issue points to a problem in the data-plane of the library.This issue points to a problem in the data-plane of the library.bugThis issue requires a change to an existing behavior in the product in order to be resolved.This issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as thatThe issue doesn't require a change to the product in order to be resolved. Most issues start as that
Metadata
Metadata
Assignees
Labels
Azure.IdentityClientThis issue points to a problem in the data-plane of the library.This issue points to a problem in the data-plane of the library.bugThis issue requires a change to an existing behavior in the product in order to be resolved.This issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as thatThe issue doesn't require a change to the product in order to be resolved. Most issues start as that
I am not getting the
SharedTokenCacheCredentialto work as expected. Considering the following script:The first time, it runs as expected. At
credential.get_token(...), a browser tab opens and I am prompted to sign in. On successful sign in, it generates the token, and the script returns.On all subsequent runs, it does not behave as expected.
SharedTokenCacheCredentialshould be used, and I should not be prompted to sign in again.SharedTokenCacheCredential authentication unavailable. No accounts were found in the cache.The following workaround yields the expected behavior, but uses a "private" function from the
azure.identitypackage.from azure.identity import ( ChainedTokenCredential, InteractiveBrowserCredential, TokenCachePersistenceOptions, ) +from azure.identity._persistent_cache import _load_persistent_cache TENANT_ID = "..." cache_options = TokenCachePersistenceOptions(name="my.cache") credential = ChainedTokenCredential( SharedTokenCacheCredential( tenant_id=TENANT_ID, cache_persistence_options=cache_options, + _cache=_load_persistent_cache(cache_options), ), InteractiveBrowserCredential( tenant_id=TENANT_ID, cache_persistence_options=cache_options, ) ) credential.get_token(...)My question is: is there another solution that uses the "public" api?
My setup: