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/active-directory/develop/quickstart-daemon-app-java-acquire-token.md
+13-28Lines changed: 13 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,25 +28,10 @@ To run this sample, you need:
28
28
-[Java Development Kit (JDK)](https://openjdk.java.net/) 8 or greater
29
29
-[Maven](https://maven.apache.org/)
30
30
31
-
32
-
## Register and download your quickstart app
33
-
34
-
You have two options to start your quickstart application: Express (Option 1 below), and Manual (Option 2)
35
-
36
-
### Option 1: Register and auto configure your app and then download your code sample
37
-
38
-
1. Sign in to the [Microsoft Entra admin center](https://entra.microsoft.com) as at least an [Application Developer](../roles/permissions-reference.md#application-developer).
39
-
1. Browse to **Identity** > **Applications** > **Application registrations**.
40
-
1. Select **New registration**.
41
-
1. Enter a name for your application and select **Register**.
42
-
1. Follow the instructions to download and automatically configure your new application with just one click.
43
-
44
-
### Option 2: Register and manually configure your application and code sample
To register your application and add the app's registration information to your solution manually, follow these steps:
51
36
52
37
1. Sign in to the [Microsoft Entra admin center](https://entra.microsoft.com) as at least an [Application Developer](../roles/permissions-reference.md#application-developer).
@@ -61,10 +46,10 @@ To register your application and add the app's registration information to your
61
46
1. Select **Application permissions**.
62
47
1. Under **User** node, select **User.Read.All**, then select **Add permissions**.
63
48
64
-
####Step 2: Download the Java project
49
+
### Step 2: Download the Java project
65
50
[Download the Java daemon project](https://github.com/Azure-Samples/ms-identity-java-daemon/archive/master.zip)
66
51
67
-
####Step 3: Configure the Java project
52
+
### Step 3: Configure the Java project
68
53
69
54
1. Extract the zip file to a local folder close to the root of the disk, for example, *C:\Azure-Samples*.
70
55
1. Navigate to the sub folder **msal-client-credential-secret**.
@@ -81,18 +66,18 @@ To register your application and add the app's registration information to your
81
66
-`Enter_the_Client_Secret_Here` - replace this value with the client secret created on step 1.
82
67
83
68
>[!TIP]
84
-
>To find the values of **Application (client) ID**, **Directory (tenant) ID**, go to the app's **Overview** page in the Azure portal. To generate a new key, go to **Certificates & secrets** page.
69
+
>To find the values of **Application (client) ID**, **Directory (tenant) ID**, go to the app's **Overview** page. To generate a new key, go to **Certificates & secrets** page.
85
70
86
-
####Step 4: Admin consent
71
+
### Step 4: Admin consent
87
72
88
73
If you try to run the application at this point, you'll receive *HTTP 403 - Forbidden* error: `Insufficient privileges to complete the operation`. This error happens because any *app-only permission* requires Admin consent: a global administrator of your directory must give consent to your application. Select one of the options below depending on your role:
89
74
90
-
#####Global tenant administrator
75
+
#### Global tenant administrator
91
76
92
77
93
-
If you are a global tenant administrator, go to **API Permissions** page in **App registrations**in the Azure portal and select **Grant admin consent for {Tenant Name}** (Where {Tenant Name} is the name of your directory).
78
+
If you are a global tenant administrator, go to **API Permissions** page in **App registrations** and select **Grant admin consent for {Tenant Name}** (Where {Tenant Name} is the name of your directory).
94
79
95
-
#####Standard user
80
+
#### Standard user
96
81
97
82
If you're a standard user of your tenant, then you need to ask a global administrator to grant admin consent for your application. To do this, give the following URL to your administrator:
*`Enter_the_Application_Id_Here` - is the **Application (client) ID** for the application you registered.
106
91
107
92
108
-
####Step 5: Run the application
93
+
### Step 5: Run the application
109
94
110
95
You can test the sample directly by running the main method of ClientCredentialGrant.java from your IDE.
111
96
@@ -172,8 +157,8 @@ ConfidentialClientApplication cca =
172
157
173
158
| Where: |Description |
174
159
|---------|---------|
175
-
|`CLIENT_SECRET`| Is the client secret created for the application in Azure portal. |
176
-
|`CLIENT_ID`| Is the **Application (client) ID** for the application registered in the Azure portal. You can find this value in the app's **Overview** page in the Azure portal. |
160
+
|`CLIENT_SECRET`| Is the client secret created for the application. |
161
+
|`CLIENT_ID`| Is the **Application (client) ID** for the registered application. You can find this value in the app's **Overview** page. |
177
162
|`AUTHORITY`| The STS endpoint for user to authenticate. Usually `https://login.microsoftonline.com/{tenant}` for public cloud, where {tenant} is the name of your tenant or your tenant ID.|
178
163
179
164
### Requesting tokens
@@ -212,7 +197,7 @@ IAuthenticationResult result;
212
197
213
198
|Where:| Description |
214
199
|---------|---------|
215
-
|`SCOPE`| Contains the scopes requested. For confidential clients, this should use the format similar to `{Application ID URI}/.default` to indicate that the scopes being requested are the ones statically defined in the app object set in the Azure portal (for Microsoft Graph, `{Application ID URI}` points to `https://graph.microsoft.com`). For custom web APIs, `{Application ID URI}` is defined under the **Expose an API** section in **App registrations** in the Azure portal.|
200
+
|`SCOPE`| Contains the scopes requested. For confidential clients, this should use the format similar to `{Application ID URI}/.default` to indicate that the scopes being requested are the ones statically defined in the app object (for Microsoft Graph, `{Application ID URI}` points to `https://graph.microsoft.com`). For custom web APIs, `{Application ID URI}` is defined under the **Expose an API** section in **App registrations**.|
216
201
217
202
[!INCLUDE [Help and support](includes/error-handling-and-tips/help-support-include.md)]
To start your quickstart application, use either of the following options.
38
-
39
-
### Option 1 (Express): Register and auto configure your app and then download your code sample
40
-
41
-
1. Go to the [Azure portal - App registrations](https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade/quickStartType/AngularSpaQuickstartPage/sourceType/docs) quickstart experience.
42
-
1. Enter a name for your application.
43
-
1. Under **Supported account types**, select **Accounts in any organizational directory and personal Microsoft accounts**.
44
-
1. Select **Register**.
45
-
1. Go to the quickstart pane and follow the instructions to download and automatically configure your new application.
46
-
47
-
### Option 2 (Manual): Register and manually configure your application and code sample
48
-
49
-
#### Step 1: Register your application
50
-
51
-
1. Sign in to the [Azure portal](https://portal.azure.com/).
52
-
1. If you have access to multiple tenants, use the **Directories + subscriptions** filter :::image type="icon" source="media/common/portal-directory-subscription-filter.png" border="false"::: in the top menu to switch to the tenant in which you want to register the application.
53
-
1. Search for and select **Azure Active Directory**.
54
-
1. Under **Manage**, select **App registrations** > **New registration**.
36
+
1. Sign in to the [Microsoft Entra admin center](https://entra.microsoft.com) as at least an [Application Developer](../roles/permissions-reference.md#application-developer).
37
+
1. If access to multiple tenants is available, use the **Directories + subscriptions** filter :::image type="icon" source="media/common/portal-directory-subscription-filter.png" border="false"::: in the top menu to switch to the tenant in which you want to register the application.
38
+
1. Browse to **Identity** > **Applications** > **Application registrations**.
39
+
1. Select **New registration**.
55
40
1. Enter a **Name** for your application. Users of your app might see this name, and you can change it later.
56
41
1. Under **Supported account types**, select **Accounts in any organizational directory and personal Microsoft accounts**.
57
42
1. Select **Register**. On the app **Overview** page, note the **Application (client) ID** value for later use.
@@ -90,17 +75,17 @@ Modify the values in the `auth` section as described here:
90
75
91
76
- `Enter_the_Application_Id_Here` is the **Application (client) ID** for the application you registered.
92
77
93
-
To find the value of **Application (client) ID**, go to the app registration's **Overview** page in the Azure portal.
78
+
To find the value of **Application (client) ID**, go to the app registration's **Overview** page.
94
79
- `Enter_the_Cloud_Instance_Id_Here` is the instance of the Azure cloud. For the main or global Azure cloud, enter `https://login.microsoftonline.com`. For **national** clouds (for example, China), see [National clouds](authentication-national-cloud.md).
95
80
-`Enter_the_Tenant_info_here` is set to one of the following:
96
81
- If your application supports *accounts inthis organizational directory*, replace this value with the **Tenant ID** or **Tenant name**. For example, `contoso.microsoft.com`.
97
82
98
-
To find the value of the **Directory (tenant) ID**, go to the app registration's **Overview** page in the Azure portal.
83
+
To find the value of the **Directory (tenant) ID**, go to the app registration's **Overview** page.
99
84
- If your application supports *accounts in any organizational directory*, replace this value with `organizations`.
100
85
- If your application supports *accounts in any organizational directory and personal Microsoft accounts*, replace this value with `common`. **For this quickstart**, use `common`.
101
86
- To restrict support to *personal Microsoft accounts only*, replace this value with `consumers`.
102
87
103
-
To find the value of **Supported account types**, go to the app registration's **Overview** pagein the Azure portal.
88
+
To find the value of **Supported account types**, go to the app registration's **Overview** page.
104
89
-`Enter_the_Redirect_Uri_Here` is `http://localhost:4200/`.
105
90
106
91
The `authority` value in your *app.module.ts* should be similar to the following if you're using the main (global) Azure cloud:
To start your quickstart application, use either of the following options.
36
+
### Step 1: Register your application
37
37
38
-
### Option 1 (Express): Register and auto configure your app and then download your code sample
39
-
40
-
1. Go to the [Azure portal - App registrations](https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade/quickStartType/AngularSpaQuickstartPage/sourceType/docs) quickstart experience.
41
-
1. Enter a name for your application.
42
-
1. Under **Supported account types**, select **Accounts in any organizational directory and personal Microsoft accounts**.
43
-
1. Select **Register**.
44
-
1. Go to the quickstart pane and follow the instructions to download and automatically configure your new application.
45
-
46
-
### Option 2 (Manual): Register and manually configure your application and code sample
47
-
48
-
#### Step 1: Register your application
49
-
50
-
1. Sign in to the [Azure portal](https://portal.azure.com/).
51
-
1. If you have access to multiple tenants, use the **Directories + subscriptions** filter :::image type="icon" source="media/common/portal-directory-subscription-filter.png" border="false"::: in the top menu to switch to the tenant in which you want to register the application.
52
-
1. Search for and select **Azure Active Directory**.
53
-
1. Under **Manage**, select **App registrations** > **New registration**.
38
+
1. Sign in to the [Microsoft Entra admin center](https://entra.microsoft.com) as at least an [Application Developer](../roles/permissions-reference.md#application-developer).
39
+
1. If access to multiple tenants is available, use the **Directories + subscriptions** filter :::image type="icon" source="media/common/portal-directory-subscription-filter.png" border="false"::: in the top menu to switch to the tenant in which you want to register the application.
40
+
1. Browse to **Identity** > **Applications** > **Application registrations**.
41
+
1. Select **New registration**.
54
42
1. Enter a **Name** for your application. Users of your app might see this name, and you can change it later.
55
43
1. Under **Supported account types**, select **Accounts in any organizational directory and personal Microsoft accounts**.
56
44
1. Select **Register**. On the app **Overview** page, note the **Application (client) ID** value for later use.
@@ -59,12 +47,11 @@ To start your quickstart application, use either of the following options.
59
47
1. Set the **Redirect URI** value to `http://localhost:3000/`.
60
48
1. Select **Configure**.
61
49
62
-
####Step 2: Download the project
50
+
### Step 2: Download the project
63
51
64
52
To run the project with a web server by using Node.js, [download the core project files](https://github.com/Azure-Samples/ms-identity-javascript-v2/archive/master.zip).
65
53
66
-
67
-
#### Step 3: Configure your JavaScript app
54
+
### Step 3: Configure your JavaScript app
68
55
69
56
In the *app* folder, open the *authConfig.js* file, and then update the `clientID`, `authority`, and `redirectUri` values in the `msalConfig` object.
70
57
@@ -87,17 +74,17 @@ Modify the values in the `msalConfig` section:
87
74
88
75
-`Enter_the_Application_Id_Here` is the **Application (client) ID** for the application you registered.
89
76
90
-
To find the value of **Application (client) ID**, go to the app registration's **Overview** page in the Azure portal.
77
+
To find the value of **Application (client) ID**, go to the app registration's **Overview** page.
91
78
-`Enter_the_Cloud_Instance_Id_Here` is the Azure cloud instance. For the main or global Azure cloud, enter `https://login.microsoftonline.com`. For **national** clouds (for example, China), see [National clouds](authentication-national-cloud.md).
92
79
-`Enter_the_Tenant_info_here` is one of the following:
93
80
- If your application supports *accounts in this organizational directory*, replace this value with the **Tenant ID** or **Tenant name**. For example, `contoso.microsoft.com`.
94
81
95
-
To find the value of the **Directory (tenant) ID**, go to the app registration's **Overview** page in the Azure portal.
82
+
To find the value of the **Directory (tenant) ID**, go to the app registration's **Overview** page.
96
83
- If your application supports *accounts in any organizational directory*, replace this value with `organizations`.
97
84
- If your application supports *accounts in any organizational directory and personal Microsoft accounts*, replace this value with `common`. **For this quickstart**, use `common`.
98
85
- To restrict support to *personal Microsoft accounts only*, replace this value with `consumers`.
99
86
100
-
To find the value of **Supported account types**, go to the app registration's **Overview** page in the Azure portal.
87
+
To find the value of **Supported account types**, go to the app registration's **Overview** page.
101
88
-`Enter_the_Redirect_Uri_Here` is `http://localhost:3000/`.
102
89
103
90
The `authority` value in your *authConfig.js* should be similar to the following if you're using the main (global) Azure cloud:
0 commit comments