def revoke_tokens(self): from azure.communication.administration import CommunicationIdentityClient if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None: from azure.identity import DefaultAzureCredential identity_client = CommunicationIdentityClient( self.endpoint, DefaultAzureCredential()) else: identity_client = CommunicationIdentityClient.from_connection_string( self.connection_string) user = identity_client.create_user() tokenresponse = identity_client.issue_token(user, scopes=["chat"]) identity_client.revoke_tokens(user) print(tokenresponse)
def test_revoke_tokens_from_managed_identity(self, connection_string): endpoint, access_key = parse_connection_str(connection_string) from devtools_testutils import is_live if not is_live(): credential = FakeTokenCredential() else: credential = DefaultAzureCredential() identity_client = CommunicationIdentityClient(endpoint, credential) user = identity_client.create_user() token_response = identity_client.issue_token(user, scopes=["chat"]) identity_client.revoke_tokens(user) assert user.identifier is not None assert token_response.token is not None