You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/communication-services/concepts/identity-model.md
+14-1Lines changed: 14 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,20 @@ You can create Azure Communication Service user identities for free. The only ch
31
31
32
32
Managing a mapping between Azure Communication Services user identities and your own identity system is your responsibility as a developer, and doesn't come built-in. For example, you can add a `CommunicationServicesId` column in your existing user table to store the associated Azure Communication Services identity. A mapping design is described in more detail under [Client-server architecture](#client-server-architecture).
33
33
34
-
## Access tokens
34
+
## (Preview) Simplify identity mapping with `customId`
35
+
36
+
> [!IMPORTANT]
37
+
> This feature is available starting with the SDK version `1.4.0-beta1`.
38
+
> [!NOTE]
39
+
> This feature is currently in preview.
40
+
41
+
Previously, developers were responsible for maintaining a mapping between their own user identity system and Azure Communication Services identities. With the introduction of the `customId` parameter, you can now associate your own user identifiers—such as email addresses or internal user IDs—directly when creating a Communication Services identity.
42
+
43
+
When you create a user with a `customId`, Azure Communication Services will return the same identity if you call the method again with the same `customId`. This eliminates the need to store and manage the mapping yourself.
44
+
45
+
This feature is supported in both the SDK and REST API, and is especially useful for scenarios where you want to maintain a consistent identity across sessions, devices, or services without additional storage overhead.
46
+
47
+
## Access tokens
35
48
36
49
After you create a user identity, the end-user then needs an access token with specific scopes to participate in communications using chat or calls. For example, only a user with a token of `chat` scope can participate in chat. Only a user with a token of `voip` scope can participate in a VoIP call.
Copy file name to clipboardExpand all lines: articles/communication-services/quickstarts/identity/includes/access-tokens/access-token-js.md
+55Lines changed: 55 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -116,6 +116,40 @@ console.log(`\nCreated an identity with ID: ${identityResponse.communicationUser
116
116
117
117
Store the received identity with mapping to your application's users (for example, by storing it in your application server database).
118
118
119
+
## (Preview) Create an identity with an associated custom ID
120
+
121
+
> [!IMPORTANT]
122
+
> This feature is available starting with the SDK version `1.4.0-beta1`.
123
+
> [!NOTE]
124
+
> This feature is currently in preview.
125
+
126
+
You can create an identity with an associated `customId` to map your application's user identities to Azure Communication Services identities. When you call `createUser`with the same `customId`, the service returns the same `communicationUserId`. This eliminates the need to store the mapping yourself.
Use the `getToken` method to issue an access token for your Communication Services identity. The`scopes` parameter defines a set of access token permissions and roles. For more information, see the list of supported actions in [Identity model](../../../../concepts/identity-model.md#access-tokens). You can also construct a newinstanceof a `communicationUser` based on a string representation of the Azure Communication Service identity.
@@ -158,6 +192,27 @@ console.log(`\nIssued an access token with 'voip' scope that expires at ${expire
158
192
console.log(token);
159
193
```
160
194
195
+
### (Preview) Create an identity and issue a token in one method call including a customId
196
+
197
+
> [!IMPORTANT]
198
+
> This feature is available starting with the SDK version `1.4.0-beta1`.
199
+
> [!NOTE]
200
+
> This feature is currently in preview.
201
+
202
+
You can pass your custom ID to the `createUserAndToken` method to create an identity and issue an access token in a single call.
203
+
204
+
```javascript
205
+
// Issue an identity and an access token with a validity of 24 hours and the "voip" scope for the new identity
let identityTokenResponse = await identityClient.createUserAndToken(["voip"], { customId });
208
+
209
+
// Get the token, its expiration date, and the user from the response
210
+
const { token, expiresOn, user } = identityTokenResponse;
211
+
console.log(`\nCreated an identity withID: ${user.communicationUserId}`);
212
+
console.log(`\nIssued an access token with'voip' scope that expires at ${expiresOn}:`);
213
+
console.log(token);
214
+
```
215
+
161
216
## Refresh an access token
162
217
163
218
As tokens expire, you need to refresh them. To refresh tokens, call `getToken` again with the same identity used to issue the tokens. You also need to provide the `scopes`of the refreshed tokens.
Copy file name to clipboardExpand all lines: articles/communication-services/quickstarts/identity/includes/access-tokens/access-token-net.md
+55Lines changed: 55 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -122,6 +122,39 @@ Console.WriteLine($"\nCreated an identity with ID: {identity.Id}");
122
122
123
123
Store the received identity with mapping to your application users (for example, by storing it in your application server database).
124
124
125
+
## (Preview) Create an identity with an associated customId
126
+
127
+
> [!IMPORTANT]
128
+
> This feature is available starting with the SDK version `1.4.0-beta1`.
129
+
> [!NOTE]
130
+
> This feature is currently in preview.
131
+
132
+
You can create an identity with an associated `customId` to map your application's user identities with Azure Communication Services identities. If you call the `CreateUser` method again with the same `customId`, it will return the same `user.Id`. This eliminates the need to store the mapping yourself.
After you have a Communication Services identity, use the `GetToken` method to issue an access token for it. The `scopes` parameter defines a set of access token permissions and roles. For more information, see the list of supported actions in [Identity model](../../../../concepts/identity-model.md#access-tokens). You can also construct a new instance of `communicationUser` based on a string representation of an Azure Communication Service identity.
@@ -167,6 +200,28 @@ Console.WriteLine($"\nIssued an access token with 'voip' scope that expires at {
167
200
Console.WriteLine(token);
168
201
```
169
202
203
+
### (Preview) Create and identity and issue a token in the same request with a custom ID
204
+
205
+
> [!IMPORTANT]
206
+
> This feature is available starting with the SDK version `1.4.0-beta1`.
207
+
> [!NOTE]
208
+
> This feature is currently in preview.
209
+
210
+
You can pass your custom ID to the `CreateUserAndTokenAsync` method to create an identity and issue an access token in a single call.
211
+
212
+
```csharp
213
+
// Issue an identity and an access token with a validity of 24 hours and the "voip" scope for the new identity
Console.WriteLine($"\nCreated an identity with ID: {identity.Id}");
221
+
Console.WriteLine($"\nIssued an access token with 'voip' scope that expires at {expiresOn}:");
222
+
Console.WriteLine(token);
223
+
```
224
+
170
225
## Refresh an access token
171
226
172
227
To refresh an access token, pass an instance of the `CommunicationUserIdentifier` object into `GetTokenAsync`. If you stored this `Id` and need to create a new `CommunicationUserIdentifier`, you can do so by passing your stored `Id` into the `CommunicationUserIdentifier` constructor as follows:
0 commit comments