-
Notifications
You must be signed in to change notification settings - Fork 206
Implement remove_tokens_for_client() #666
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2178,6 +2178,19 @@ def _acquire_token_for_client( | |
telemetry_context.update_telemetry(response) | ||
return response | ||
|
||
def remove_tokens_for_client(self): | ||
"""Remove all tokens that were previously acquired via | ||
:func:`~acquire_token_for_client()` for the current client.""" | ||
for env in [self.authority.instance] + self._get_authority_aliases( | ||
self.authority.instance): | ||
for at in self.token_cache.find(TokenCache.CredentialType.ACCESS_TOKEN, query={ | ||
"client_id": self.client_id, | ||
"environment": env, | ||
"home_account_id": None, # These are mostly app-only tokens | ||
}): | ||
Comment on lines
+2186
to
+2190
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Luckily This means all access tokens for a service principal from all tenants will be removed. However, this brings up another question: what if I only want to remove the access token for a service principal in a specific tenant? |
||
self.token_cache.remove_at(at) | ||
# acquire_token_for_client() obtains no RTs, so we have no RT to remove | ||
|
||
def acquire_token_on_behalf_of(self, user_assertion, scopes, claims_challenge=None, **kwargs): | ||
"""Acquires token using on-behalf-of (OBO) flow. | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.