1111DESCRIPTION:
1212 These samples demonstrate creating a user, issuing a token, revoking a token and deleting a user.
1313
14- ///authenticating a client via a connection string
1514USAGE:
1615 python identity_samples.py
1716 Set the environment variables with your own values before running the sample:
1817 1) AZURE_COMMUNICATION_SERVICE_ENDPOINT - Communication Service endpoint url
18+ 2) AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING - the connection string in your ACS account
19+ 3) AZURE_CLIENT_ID - the client ID of your active directory application
20+ 4) AZURE_CLIENT_SECRET - the secret of your active directory application
21+ 5) AZURE_TENANT_ID - the tenant ID of your active directory application
1922"""
2023import os
2124
@@ -40,7 +43,7 @@ def get_token(self):
4043 else :
4144 identity_client = CommunicationIdentityClient .from_connection_string (self .connection_string )
4245 user = identity_client .create_user ()
43- print ("Getting token for: " + user .properties [ 'id' ] )
46+ print ("Getting token for: " + user .identifier )
4447 tokenresponse = identity_client .get_token (user , scopes = [CommunicationTokenScope .CHAT ])
4548 print ("Token issued with value: " + tokenresponse .token )
4649
@@ -71,7 +74,7 @@ def create_user(self):
7174 identity_client = CommunicationIdentityClient .from_connection_string (self .connection_string )
7275 print ("Creating new user" )
7376 user = identity_client .create_user ()
74- print ("User created with id:" + user .properties [ 'id' ] )
77+ print ("User created with id:" + user .identifier )
7578
7679 def create_user_and_token (self ):
7780 from azure .communication .identity import (
@@ -85,7 +88,7 @@ def create_user_and_token(self):
8588 identity_client = CommunicationIdentityClient .from_connection_string (self .connection_string )
8689 print ("Creating new user with token" )
8790 user , tokenresponse = identity_client .create_user_and_token (scopes = [CommunicationTokenScope .CHAT ])
88- print ("User created with id:" + user .properties [ 'id' ] )
91+ print ("User created with id:" + user .identifier )
8992 print ("Token issued with value: " + tokenresponse .token )
9093
9194 def delete_user (self ):
@@ -97,9 +100,9 @@ def delete_user(self):
97100 else :
98101 identity_client = CommunicationIdentityClient .from_connection_string (self .connection_string )
99102 user = identity_client .create_user ()
100- print ("Deleting user: " + user .properties [ 'id' ] )
103+ print ("Deleting user: " + user .identifier )
101104 identity_client .delete_user (user )
102- print (user .properties [ 'id' ] + " deleted" )
105+ print (user .identifier + " deleted" )
103106
104107if __name__ == '__main__' :
105108 sample = CommunicationIdentityClientSamples ()
0 commit comments