Skip to content

Commit

Permalink
Updated identity samples (#18189)
Browse files Browse the repository at this point in the history
  • Loading branch information
lsundaralingam authored Apr 21, 2021
1 parent e33048c commit 127516e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def get_token(self):
else:
identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string)
user = identity_client.create_user()
print("Getting token for: " + user.identifier)
print("Getting token for: " + user.properties.get('id'))
tokenresponse = identity_client.get_token(user, scopes=[CommunicationTokenScope.CHAT])
print("Token issued with value: " + tokenresponse.token)

Expand Down Expand Up @@ -74,7 +74,7 @@ def create_user(self):
identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string)
print("Creating new user")
user = identity_client.create_user()
print("User created with id:" + user.identifier)
print("User created with id:" + user.properties.get('id'))

def create_user_and_token(self):
from azure.communication.identity import (
Expand All @@ -88,7 +88,7 @@ def create_user_and_token(self):
identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string)
print("Creating new user with token")
user, tokenresponse = identity_client.create_user_and_token(scopes=[CommunicationTokenScope.CHAT])
print("User created with id:" + user.identifier)
print("User created with id:" + user.properties.get('id'))
print("Token issued with value: " + tokenresponse.token)

def delete_user(self):
Expand All @@ -100,9 +100,9 @@ def delete_user(self):
else:
identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string)
user = identity_client.create_user()
print("Deleting user: " + user.identifier)
print("Deleting user: " + user.properties.get('id'))
identity_client.delete_user(user)
print(user.identifier + " deleted")
print(user.properties.get('id') + " deleted")

if __name__ == '__main__':
sample = CommunicationIdentityClientSamples()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async def get_token(self):

async with identity_client:
user = await identity_client.create_user()
print("Issuing token for: " + user.identifier)
print("Issuing token for: " + user.properties.get('id'))
tokenresponse = await identity_client.get_token(user, scopes=[CommunicationTokenScope.CHAT])
print("Token issued with value: " + tokenresponse.token)

Expand Down Expand Up @@ -76,7 +76,7 @@ async def create_user(self):
async with identity_client:
print("Creating new user")
user = await identity_client.create_user()
print("User created with id:" + user.identifier)
print("User created with id:" + user.properties.get('id'))

async def create_user_and_token(self):
from azure.communication.identity.aio import CommunicationIdentityClient
Expand All @@ -90,7 +90,7 @@ async def create_user_and_token(self):
async with identity_client:
print("Creating new user with token")
user, tokenresponse = await identity_client.create_user_and_token(scopes=[CommunicationTokenScope.CHAT])
print("User created with id:" + user.identifier)
print("User created with id:" + user.properties.get('id'))
print("Token issued with value: " + tokenresponse.token)

async def delete_user(self):
Expand All @@ -103,9 +103,9 @@ async def delete_user(self):

async with identity_client:
user = await identity_client.create_user()
print("Deleting user: " + user.identifier)
print("Deleting user: " + user.properties.get('id'))
await identity_client.delete_user(user)
print(user.identifier + " deleted")
print(user.properties.get('id') + " deleted")

async def main():
sample = CommunicationIdentityClientSamples()
Expand Down

0 comments on commit 127516e

Please sign in to comment.