Skip to content

Commit 849c295

Browse files
minnieliuMinnie Liu
and
Minnie Liu
authored
[Communication] - Identity - Update README (#17091)
* Update Identity Readme * Revert Readme * Update Identity Readme * Address reviews Co-authored-by: Minnie Liu <[email protected]>
1 parent 52406b6 commit 849c295

File tree

1 file changed

+10
-11
lines changed
  • sdk/communication/azure-communication-identity

1 file changed

+10
-11
lines changed

sdk/communication/azure-communication-identity/README.md

+10-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Azure Communication Identity Package client library for Python
44

5-
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.
5+
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.
66

77
[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)
88

@@ -51,21 +51,12 @@ The following section provides several code snippets covering some of the most c
5151

5252
### Creating a new user
5353

54-
Use the `create_user` method to create a new user.
54+
Use the `create_user` method to create a new user.
5555
```python
5656
user = identity_client.create_user()
5757
print("User created with id:" + user.identifier)
5858
```
5959

60-
Alternatively, use the `create_user_and_token` method to create a new user and issue a token for it.\
61-
For this option, a list of `CommunicationTokenScope` must be defined (see "Issuing an access token" for more information)
62-
63-
```python
64-
user, tokenresponse = identity_client.create_user_and_token(scopes=[CommunicationTokenScope.CHAT])
65-
print("User id:" + user.identifier)
66-
print("Token issued with value: " + tokenresponse.token)
67-
```
68-
6960
### Issuing or Refreshing an access token for a user
7061

7162
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`.
7768
tokenresponse = identity_client.get_token(user, scopes=[CommunicationTokenScope.CHAT])
7869
print("Token issued with value: " + tokenresponse.token)
7970
```
71+
### Creating a user and a token in a single request
72+
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.
73+
74+
```python
75+
user, tokenresponse = identity_client.create_user_and_token(scopes=[CommunicationTokenScope.CHAT])
76+
print("User id:" + user.identifier)
77+
print("Token issued with value: " + tokenresponse.token)
78+
```
8079

8180
### Revoking a user's access tokens
8281

0 commit comments

Comments
 (0)