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
In this quickstart, you download and run a code sample that demonstrates how a Java application can get an access token using the app's identity to call the Microsoft Graph API and display a [list of users](/graph/api/user-list) in the directory. The code sample demonstrates how an unattended job or Windows service can run with an application identity, instead of a user's identity.
21
21
22
-
> [!div renderon="docs"]
23
-
> 
24
-
25
22
## Prerequisites
26
23
27
24
To run this sample, you need:
28
25
29
26
-[Java Development Kit (JDK)](https://openjdk.java.net/) 8 or greater
30
27
-[Maven](https://maven.apache.org/)
31
28
32
-
> [!div renderon="docs"]
33
-
> ## Register and download your quickstart app
34
-
35
-
> [!div renderon="docs" class="sxs-lookup"]
36
-
>
37
-
> You have two options to start your quickstart application: Express (Option 1 below), and Manual (Option 2)
38
-
>
39
-
> ### Option 1: Register and auto configure your app and then download your code sample
40
-
>
41
-
> 1. Go to the <ahref="https://portal.azure.com/?Microsoft_AAD_RegisteredApps=true#blade/Microsoft_AAD_RegisteredApps/applicationsListBlade/quickStartType/JavaDaemonQuickstartPage/sourceType/docs"target="_blank">Azure portal - App registrations</a> quickstart experience.
42
-
> 1. Enter a name for your application and select **Register**.
43
-
> 1. Follow the instructions to download and automatically configure your new application with just one click.
44
-
>
45
-
> ### Option 2: Register and manually configure your application and code sample
46
-
47
-
> [!div renderon="docs"]
48
-
> #### Step 1: Register your application
49
-
> To register your application and add the app's registration information to your solution manually, follow these steps:
50
-
>
51
-
> 1. Sign in to the <ahref="https://portal.azure.com/"target="_blank">Azure portal</a>.
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**.
55
-
> 1. Enter a **Name** for your application, for example `Daemon-console`. Users of your app might see this name, and you can change it later.
56
-
> 1. Select **Register**.
57
-
> 1. Under **Manage**, select **Certificates & secrets**.
58
-
> 1. Under **Client secrets**, select **New client secret**, enter a name, and then select **Add**. Record the secret value in a safe location for use in a later step.
59
-
> 1. Under **Manage**, select **API Permissions** > **Add a permission**. Select **Microsoft Graph**.
60
-
> 1. Select **Application permissions**.
61
-
> 1. Under **User** node, select **User.Read.All**, then select **Add permissions**.
62
-
63
-
> [!div class="sxs-lookup" renderon="portal"]
64
-
> ### Download and configure the quickstart app
65
-
>
66
-
> #### Step 1: Configure the application in Azure portal
67
-
> For the code sample for this quickstart to work, you need to create a client secret, and add Graph API's **User.Read.All** application permission.
> [Download the code sample](https://github.com/Azure-Samples/ms-identity-java-daemon/archive/master.zip)
81
44
82
-
> [!div class="sxs-lookup" renderon="portal"]
45
+
> [!div class="sxs-lookup"]
83
46
> > [!NOTE]
84
47
> > `Enter_the_Supported_Account_Info_Here`
85
48
86
-
> [!div renderon="docs"]
87
-
> #### Step 3: Configure the Java project
88
-
>
89
-
> 1. Extract the zip file to a local folder close to the root of the disk, for example, *C:\Azure-Samples*.
90
-
> 1. Navigate to the sub folder **msal-client-credential-secret**.
91
-
> 1. Edit *src\main\resources\application.properties* and replace the values of the fields `AUTHORITY`, `CLIENT_ID`, and `SECRET` with the following snippet:
> - `Enter_the_Application_Id_Here` - is the **Application (client) ID** for the application you registered.
100
-
> - `Enter_the_Tenant_Id_Here` - replace this value with the **Tenant Id** or **Tenant name** (for example, contoso.microsoft.com).
101
-
> - `Enter_the_Client_Secret_Here` - replace this value with the client secret created on step 1.
102
-
>
103
-
> > [!TIP]
104
-
> > 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.
105
-
106
-
> [!div class="sxs-lookup" renderon="portal"]
107
-
> #### Step 3: Admin consent
108
-
109
-
> [!div renderon="docs"]
110
-
> #### Step 4: Admin consent
49
+
#### Step 3: Admin consent
111
50
112
51
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:
113
52
114
53
##### Global tenant administrator
115
54
116
-
> [!div renderon="docs"]
117
-
> 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).
118
-
119
-
> [!div renderon="portal" class="sxs-lookup"]
55
+
> [!div class="sxs-lookup"]
120
56
> If you are a global administrator, go to **API Permissions** page select **Grant admin consent for Enter_the_Tenant_Name_Here**.
121
57
> > [!div id="apipermissionspage"]
122
58
> > [Go to the API Permissions page]()
@@ -129,16 +65,9 @@ If you're a standard user of your tenant, then you need to ask a global administ
0 commit comments