diff --git a/sdk/communication/azure-communication-identity/README.md b/sdk/communication/azure-communication-identity/README.md index d642f33efbcf..2b052765b6f4 100644 --- a/sdk/communication/azure-communication-identity/README.md +++ b/sdk/communication/azure-communication-identity/README.md @@ -2,7 +2,7 @@ # Azure Communication Identity Package client library for Python -Azure Communication Identity client package is intended to be used to setup the basics for opening a way to use Azure Communication Service offerings. This package helps to create identities user tokens to be used by other client packages such as chat, calling, sms. +Azure Communication Identity client package is intended to be used to setup the basics for opening a way to use Azure Communication Service offerings. This package helps to create identity user tokens to be used by other client packages such as chat, calling, sms. [Source code](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/communication/azure-communication-identity) | [Package (Pypi)](https://pypi.org/project/azure-communication-identity/) | [API reference documentation](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/communication/azure-communication-identity) | [Product documentation](https://docs.microsoft.com/azure/communication-services/quickstarts/access-tokens?pivots=programming-language-python) @@ -51,21 +51,12 @@ The following section provides several code snippets covering some of the most c ### Creating a new user -Use the `create_user` method to create a new user. +Use the `create_user` method to create a new user. ```python user = identity_client.create_user() print("User created with id:" + user.identifier) ``` -Alternatively, use the `create_user_and_token` method to create a new user and issue a token for it.\ -For this option, a list of `CommunicationTokenScope` must be defined (see "Issuing an access token" for more information) - -```python -user, tokenresponse = identity_client.create_user_and_token(scopes=[CommunicationTokenScope.CHAT]) -print("User id:" + user.identifier) -print("Token issued with value: " + tokenresponse.token) -``` - ### Issuing or Refreshing an access token for a user Use the `get_token` method to issue or refresh a scoped access token for the user. \ @@ -77,6 +68,14 @@ Pass in the user object as a parameter, and a list of `CommunicationTokenScope`. tokenresponse = identity_client.get_token(user, scopes=[CommunicationTokenScope.CHAT]) print("Token issued with value: " + tokenresponse.token) ``` +### Creating a user and a token in a single request +For convenience, use `create_user_and_token` to create a new user and issue a token with one function call. This translates into a single web request as opposed to creating a user first and then issuing a token. + +```python +user, tokenresponse = identity_client.create_user_and_token(scopes=[CommunicationTokenScope.CHAT]) +print("User id:" + user.identifier) +print("Token issued with value: " + tokenresponse.token) +``` ### Revoking a user's access tokens