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/quickstarts/identity/includes/access-tokens/access-token-az-cli.md
+16-14Lines changed: 16 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,22 +18,24 @@ ms.author: dademath
18
18
- An active Communication Services resource and connection string. [Create a Communication Services resource](../../../create-communication-resource.md?#access-your-connection-strings-and-service-endpoints-using-azure-cli).
Add the Azure Communication Services extension for Azure CLI by using the `az extension` command.
24
+
25
+
Add the Azure Communication Services extension for Azure CLI using the `az extension` command.
25
26
26
27
```azurecli-interactive
27
28
az extension add --name communication
28
29
```
29
30
30
31
### Sign in to Azure CLI
31
-
You'll need to [sign in to Azure CLI](/cli/azure/authenticate-azure-cli). You can sign in running the ```az login``` command from the terminal and providing your credentials.
32
+
33
+
You need to [sign in to Azure CLI](/cli/azure/authenticate-azure-cli). You can sign in running the ```az login``` command from the terminal, then provide your credentials.
32
34
33
35
34
36
### (Optional) Use Azure CLI identity operations without passing in a connection string
35
37
36
-
You can configure the `AZURE_COMMUNICATION_CONNECTION_STRING` environment variable to use Azure CLI identity operations without having to use `--connection_string` to pass in the connection string. To configure an environment variable, open a console window and select your operating system from the below tabs. Replace `<yourConnectionString>` with your actual connection string.
38
+
You can configure the `AZURE_COMMUNICATION_CONNECTION_STRING` environment variable to use Azure CLI identity operations without having to use `--connection_string` to pass in the connection string. To configure an environment variable, open a console window and select your operating system from the following tabs. Replace `<yourConnectionString>` with your actual connection string.
37
39
38
40
#### [Windows](#tab/windows)
39
41
@@ -43,7 +45,7 @@ Open a console window and enter the following command:
After you add the environment variable, you may need to restart any running programs that will need to read the environment variable, including the console window. For example, if you're using Visual Studio as your editor, restart Visual Studio before running the example.
48
+
After you add the environment variable, you might need to restart any running programs that need to read the environment variable, including the console window. For example, if you're using Visual Studio as your editor, restart Visual Studio before running the example.
47
49
48
50
#### [macOS](#tab/unix)
49
51
@@ -53,7 +55,7 @@ Edit your **`.zshrc`**, and add the environment variable:
After you add the environment variable, run `source ~/.zshrc` from your console window to make the changes effective. If you created the environment variable with your IDE open, you may need to close and reopen the editor, IDE, or shell in order to access the variable.
58
+
After you add the environment variable, run `source ~/.zshrc` from your console window to make the changes effective. If you created the environment variable with your IDE open, you might need to close and reopen the editor, IDE, or shell in order to access the variable.
57
59
58
60
#### [Linux](#tab/linux)
59
61
@@ -63,7 +65,7 @@ Edit your **`.bash_profile`**, and add the environment variable:
After you add the environment variable, run `source ~/.bash_profile` from your console window to make the changes effective. If you created the environment variable with your IDE open, you may need to close and reopen the editor, IDE, or shell in order to access the variable.
68
+
After you add the environment variable, run `source ~/.bash_profile` from your console window to make the changes effective. If you created the environment variable with your IDE open, you might need to close and reopen the editor, IDE, or shell in order to access the variable.
67
69
68
70
---
69
71
@@ -79,7 +81,7 @@ Open a console window and enter the following command:
After you add the environment variable, you may need to restart any running programs that will need to read the environment variable, including the console window. For example, if you're using Visual Studio as your editor, restart Visual Studio before running the example.
84
+
After you add the environment variable, you might need to restart any running programs that need to read the environment variable, including the console window. For example, if you're using Visual Studio as your editor, restart Visual Studio before running the example.
83
85
84
86
#### [macOS](#tab/unix)
85
87
@@ -89,7 +91,7 @@ Edit your **`.zshrc`**, and add the environment variable:
After you add the environment variable, run `source ~/.zshrc` from your console window to make the changes effective. If you created the environment variable with your IDE open, you may need to close and reopen the editor, IDE, or shell in order to access the variable.
94
+
After you add the environment variable, run `source ~/.zshrc` from your console window to make the changes effective. If you created the environment variable with your IDE open, you might need to close and reopen the editor, IDE, or shell in order to access the variable.
93
95
94
96
#### [Linux](#tab/linux)
95
97
@@ -99,7 +101,7 @@ Edit your **`.bash_profile`**, and add the environment variable:
After you add the environment variable, run `source ~/.bash_profile` from your console window to make the changes effective. If you created the environment variable with your IDE open, you may need to close and reopen the editor, IDE, or shell in order to access the variable.
104
+
After you add the environment variable, run `source ~/.bash_profile` from your console window to make the changes effective. If you created the environment variable with your IDE open, you might need to close and reopen the editor, IDE, or shell in order to access the variable.
103
105
104
106
---
105
107
@@ -159,7 +161,7 @@ Access tokens are short-lived credentials that need to be reissued. Not doing so
### Exchange a Microsoft Entra access token of the Teams User for a Communication Identity access token
164
+
### Exchange a Microsoft Entra access token of the Teams user for a Communication Identity access token
163
165
164
166
Use the `token get-for-teams-user` command to issue an access token for the Teams user that can be used with the Azure Communication Services SDKs.
165
167
@@ -171,12 +173,12 @@ Make this replacement in the code:
171
173
172
174
- Replace `<yourConnectionString>` with your connection string.
173
175
- Replace `<yourAadUser>` with your Microsoft Entra userId.
174
-
- Replace `<yourAadApplication>` with your Microsoft Entra application Id.
176
+
- Replace `<yourAadApplication>` with your Microsoft Entra application ID.
175
177
- Replace `<yourAadToken>` with your Microsoft Entra access token.
176
178
177
179
### Revoke access tokens
178
180
179
-
You might occasionally need to explicitly revoke an access token. For example, you would do so when application users change the password they use to authenticate to your service. The `token revoke` command invalidates all active access tokens that were issued to the identity.
181
+
You might need to explicitly revoke an access token. For example, you would do so when application users change the password they use to authenticate to your service. The `token revoke` command invalidates all active access tokens that were issued to the identity.
180
182
181
183
```azurecli-interactive
182
184
az communication identity token revoke --user "<userId>" --connection-string "<yourConnectionString>"
@@ -189,7 +191,7 @@ Make this replacement in the code:
189
191
190
192
### Delete an identity
191
193
192
-
When you delete an identity, you revoke all active access tokens and prevent the further issuance of access tokens for the identity. Doing so also removes all persisted content that's associated with the identity.
194
+
When you delete an identity, you revoke all active access tokens and prevent the further issuance of access tokens for the identity. Doing so also removes all persisted content associated with the identity.
193
195
194
196
```azurecli-interactive
195
197
az communication identity user delete --user "<userId>" --connection-string "<yourConnectionString>"
Copy file name to clipboardExpand all lines: articles/communication-services/quickstarts/identity/includes/access-tokens/access-token-az-portal.md
+10-6Lines changed: 10 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,16 +15,20 @@ ms.custom: mode-other
15
15
16
16
## Prerequisites
17
17
18
-
- An [Azure Communication Services resource](../../../create-communication-resource.md)
18
+
- An [Azure Communication Services resource](../../../create-communication-resource.md).
19
19
20
20
## Create the access tokens
21
21
22
-
In the [Azure portal](https://portal.azure.com), navigate to the **Identities & User Access Tokens** blade within your Communication Services resource.
22
+
1.In the [Azure portal](https://portal.azure.com), navigate to the **Identities & User Access Tokens** blade in your Communication Services resource.
23
23
24
-
Choose the scope of the access tokens. You can select none, one, or multiple. Click **Generate**.
24
+
2.Choose the scope of the access tokens. You can choose none, one, or multiple services.
25
25
26
-

26
+
3.Select **Generate**.
27
27
28
-
You'll see an identity and corresponding user access token generated. You can copy these strings and use them in the [sample apps](../../../../samples/overview.md) and other testing scenarios.
28
+
:::image type="content" source="../../media/quick-create-identity-choose-scopes.png" alt-text="Screenshot that shows the scopes of the identity and access tokens where you select Generate." lightbox="../../media/quick-create-identity-choose-scopes.png":::
29
29
30
-

30
+
The system generates an identity and corresponding user access token.
31
+
32
+
4. Copy these strings and use them in the [sample apps](../../../../samples/overview.md) and other testing scenarios.
33
+
34
+
:::image type="content" source="../../media/quick-create-identity-generated.png" alt-text="Screenshot that shows the identity and access tokens with expiration date" lightbox="../../media/quick-create-identity-generated.png":::
Copy file name to clipboardExpand all lines: articles/communication-services/quickstarts/identity/includes/access-tokens/access-token-java.md
+34-32Lines changed: 34 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,23 +20,24 @@ ms.author: tchladek
20
20
- An active Communication Services resource and connection string. [Create a Communication Services resource](../../../create-communication-resource.md).
21
21
22
22
## Final code
23
-
Find the finalized code for this quickstart on [GitHub](https://github.com/Azure-Samples/communication-services-java-quickstarts/tree/main/access-token-quickstart).
23
+
24
+
Find the finalized code at [GitHub](https://github.com/Azure-Samples/communication-services-java-quickstarts/tree/main/access-token-quickstart).
24
25
25
26
## Set up your environment
26
27
27
28
### Create a new Java application
28
29
29
-
In a terminal or Command Prompt window, go to the directory where you want to create your Java application. To generate a Java project from the maven-archetype-quickstart template, run the following code:
30
+
In a terminal or command prompt window, go to the directory where you want to create your Java application. To generate a Java project from the maven-archetype-quickstart template, run the following code:
You'll notice that the `generate` task creates a directory with the same name as `artifactId`. Under this directory, the *src/main/java* directory contains the project source code, the *src/test/java* directory contains the test source, and the *pom.xml* file is the project's Project Object Model, or POM. This file is used for project configuration parameters.
36
+
Notice that the `generate` task creates a directory with the same name as `artifactId`. Under this directory, the `src/main/java` directory contains the project source code, the `src/test/java` directory contains the test source, and the `pom.xml` file is the project's Project Object Model, or POM. This file is used for project configuration parameters.
36
37
37
38
### Install the Communication Services packages
38
39
39
-
Open the *pom.xml* file in your text editor. Add the following dependency element to the group of dependencies:
40
+
Open the `pom.xml` file in your text editor. Add the following dependency element to the group of dependencies:
40
41
41
42
```xml
42
43
<dependency>
@@ -46,14 +47,14 @@ Open the *pom.xml* file in your text editor. Add the following dependency elemen
46
47
</dependency>
47
48
```
48
49
49
-
This code instructs Maven to install the Communication Services Identity SDK, which you'll use later.
50
+
This code instructs Maven to install the Communication Services Identity SDK, which you need to use later.
50
51
51
52
### Set up the app framework
52
53
53
-
In the project directory, do the following:
54
+
In the project directory, complete the following steps:
54
55
55
-
1. Go to the */src/main/java/com/communication/quickstart* directory.
56
-
1. Open the *App.java* file in your editor.
56
+
1. Go to the `/src/main/java/com/communication/quickstart` directory.
57
+
1. Open the `App.java` file in your editor.
57
58
1. Replace the `System.out.println("Hello world!");` statement.
58
59
1. Add `import` directives.
59
60
@@ -83,11 +84,11 @@ public class App
83
84
84
85
## Authenticate the client
85
86
86
-
Instantiate a `CommunicationIdentityClient` with your resource's access key and endpoint. For more information, see the "Store your connection string" section of [Create and manage Communication Services resources](../../../create-communication-resource.md#store-your-connection-string).
87
+
Instantiate a `CommunicationIdentityClient` with your resource's access key and endpoint. For more information, see [Create and manage Communication Services resources > Store your connection string](../../../create-communication-resource.md#store-your-connection-string).
87
88
88
-
In addition, you can initialize the client with any custom HTTP client that implements the `com.azure.core.http.HttpClient` interface.
89
+
You can also initialize the client with any custom HTTP client that implements the `com.azure.core.http.HttpClient` interface.
89
90
90
-
In the *App.java* file, add the following code to the `main` method:
91
+
In the `App.java` file, add the following code to the `main` method:
91
92
92
93
```java
93
94
// You can find your endpoint and access key from your resource in the Azure portal
@@ -111,7 +112,7 @@ CommunicationIdentityClient communicationIdentityClient = new CommunicationIdent
111
112
.buildClient();
112
113
```
113
114
114
-
If you've already set up a Microsoft Entra application, you can [authenticate by using Microsoft Entra ID](../../../identity/service-principal.md).
115
+
If you already set up a Microsoft Entra application, you can [authenticate by using Microsoft Entra ID](../../../identity/service-principal.md).
@@ -132,7 +133,7 @@ CommunicationUserIdentifier user = communicationIdentityClient.createUser();
132
133
System.out.println("\nCreated an identity with ID: "+ user.getId());
133
134
```
134
135
135
-
The created identity is required later for issuing access tokens. Store the received identity with mapping to your application's users (for example, by storing it in your application server database).
136
+
The created identity is required later to issue access tokens. Store the received identity with mapping to your application's users (for example, by storing it in your application server database).
System.out.println("\nIssued an access token with 'voip' scope that expires at: "+ expiresAt +": "+ token);
150
151
```
151
152
152
-
Access tokens are short-lived credentials that need to be reissued. Not doing so might cause a disruption of your application users' experience. The `expiresAt` property indicates the lifetime of the access token.
153
+
Access tokens are short-lived credentials that need to be reissued. Not doing so might cause a disruption of your application user experience. The `expiresAt` property indicates the lifetime of the access token.
153
154
154
155
## Set a custom token expiration time
155
156
156
-
The default token expiration time is 24 hours, but you can configure it by providing a value between an hour and 24 hours to the optional parameter `tokenExpiresIn`. When requesting a new token, it's recommended that you specify the expected typical length of a communication session for the token expiration time.
157
+
The default token expiration time is 24 hours, but you can configure it by providing a value between an hour and 24 hours to the optional parameter `tokenExpiresIn`. When requesting a new token, specify the expected typical length of a communication session for the token expiration time.
157
158
158
159
```java
159
160
// Issue an access token with a validity of an hour and the "voip" scope for a user identity
@@ -164,8 +165,7 @@ AccessToken accessToken = communicationIdentityClient.getToken(user, scopes, tok
164
165
165
166
## Create an identity and issue a token in one request
166
167
167
-
Alternatively, you can use the 'createUserAndToken' method to create a new entry in the directory with a unique `Id` and
168
-
issue an access token at the same time.
168
+
Alternatively, you can use the 'createUserAndToken' method to create a new entry in the directory with a unique `Id` and issue an access token at the same time.
169
169
170
170
```java
171
171
//Create an identity and issue token with a validity of 24 hours in one call
You might occasionally need to explicitly revoke an access token. For example, you would do so when application users change the password they use to authenticate to your service. The `revokeTokens` method invalidates all active access tokens for a particular user. In the following code, you can use the previously created user.
194
+
You might need to explicitly revoke an access token. For example, you would do so when application users change the password they use to authenticate to your service. The `revokeTokens` method invalidates all active access tokens for a particular user. In the following code, you can use the previously created user.
195
195
196
196
```java
197
197
communicationIdentityClient.revokeTokens(user);
@@ -200,7 +200,7 @@ System.out.println("\nSuccessfully revoked all access tokens for user identity w
200
200
201
201
## Delete an identity
202
202
203
-
When you delete an identity, you revoke all active access tokens and prevent the further issuance of access tokens for the identity. Doing so also removes all persisted content that's associated with the identity.
203
+
When you delete an identity, you revoke all active access tokens and prevent the further issuance of access tokens for the identity. Doing so also removes all persisted content associated with the identity.
204
204
205
205
```java
206
206
communicationIdentityClient.deleteUser(user);
@@ -209,25 +209,27 @@ System.out.println("\nDeleted the user identity with ID: " + user.getId());
209
209
210
210
## Run the code
211
211
212
-
Go to the directory that contains the *pom.xml* file, and then compile the project by using the following `mvn` command:
212
+
1.Go to the directory that contains the `pom.xml` file.
213
213
214
-
```console
215
-
mvn compile
216
-
```
214
+
2. Compile the project using the following `mvn` command:
217
215
218
-
Then, build the package:
216
+
```console
217
+
mvn compile
218
+
```
219
219
220
-
```console
221
-
mvn package
222
-
```
220
+
3. build the package:
223
221
224
-
Run the following `mvn` command to execute the app:
0 commit comments