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: 2-WebApp-graph-user/2-1-Call-MSGraph/README.md
+23-13Lines changed: 23 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ endpoint: Microsoft identity platform
14
14
15
15
## Scenario
16
16
17
-
Starting from a .NET Core 2.2 MVC Web app that uses OpenID Connect to sign in users, this phase of the tutorial shows how to call Microsoft Graph /me endpoint on behalf of the signed-in user. It leverages the ASP.NET Core OpenID Connect middleware and Microsoft Authentication Library for .NET (MSAL.NET). Their complexities where encapsultated into the `Microsoft.Identity.Web` reusable library project part of this tutorial. Once again the notion of ASP.NET services injected by dependency injection is heavily used.
17
+
Starting from a .NET Core 2.2 MVC Web app that uses OpenID Connect to sign in users, this phase of the tutorial shows how to call Microsoft Graph /me endpoint on behalf of the signed-in user. It leverages the ASP.NET Core OpenID Connect middleware and Microsoft Authentication Library for .NET (MSAL.NET). Their complexities where encapsulated into the `Microsoft.Identity.Web` reusable library project part of this tutorial. Once again the notion of ASP.NET services injected by dependency injection is heavily used.
18
18
19
19

20
20
@@ -28,17 +28,22 @@ To run this sample:
28
28
29
29
### Step 1: Register the sample with your Azure AD tenant
30
30
31
-
You first need to [register](https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/tree/aspnetcore2-2#step-1-register-the-sample-with-your-azure-ad-tenant) your app as described in [the first tutorial](https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/tree/aspnetcore2-2)
31
+
You first need to [register](../../1-WebApp-OIDC/1-1-MyOrg#step-1-register-the-sample-with-your-azure-ad-tenant) your app as described in [the first tutorial](../../1-WebApp-OIDC/1-1-MyOrg)
32
32
33
33
Then follow the following extra set of steps:
34
34
35
-
1. From the **Certificates & secrets** page, for your app registration, in the **Client secrets** section, choose **New client secret**:
36
-
37
-
- Type a key description (of instance `app secret`),
38
-
- Select a key duration of either **In 1 year**, **In 2 years**, or **Never Expires**.
39
-
- When you press the **Add** button, the key value will be displayed, copy, and save the value in a safe location.
40
-
- You'll need this key later to configure the project in Visual Studio. This key value will not be displayed again, nor retrievable by any other means.
41
-
1. In the list of pages for the app, select **API permissions**, and notice that a delegated permission is set by default to Microsoft Graph for the scope **User.Read**
35
+
1. In the app's registration screen, click on the **Certificates & secrets** blade in the left to open the page where we can generate secrets and upload certificates.
36
+
1. In the **Client secrets** section, click on **New client secret**:
37
+
- Type a key description (for instance `app secret`),
38
+
- Select one of the available key durations (**In 1 year**, **In 2 years**, or **Never Expires**) as per your security concerns.
39
+
- The generated key value will be displayed when you click the **Add** button. Copy the generated value for use in the steps later.
40
+
- You'll need this key later in your code's configuration files. This key value will not be displayed again, and is not retrievable by any other means, so make sure to note it from the Azure portal before navigating to any other screen or blade.
41
+
1. In the app's registration screen, click on the **API permissions** blade in the left to open the page where we add access to the Apis that your application needs.
42
+
- Click the **Add permissions** button and then,
43
+
- Ensure that the **Microsoft APIs** tab is selected.
44
+
- In the *Commonly used Microsoft APIs* section, click on **Microsoft Graph**
45
+
- In the **Delegated permissions** section, select the **User.Read** in the list. Use the search box if necessary.
46
+
- Click on the **Add permissions** button in the bottom.
42
47
43
48
### Step 2: Download/Clone/Go to the folder containing the sample code and build the application
44
49
@@ -56,11 +61,16 @@ Go to the `"2-WebApp-graph-user\2-1-Call-MSGraph"` folder
56
61
cd"2-WebApp-graph-user\2-1-Call-MSGraph"
57
62
```
58
63
59
-
In the appsettings.json file, replace, if you have not already:
64
+
#### Configure the webApp app (WebApp-OpenIDConnect-DotNet-code-v2) to use your app registration
65
+
66
+
Open the project in your IDE (like Visual Studio) to configure the code.
67
+
>In the steps below, "ClientID" is the same as "Application ID" or "AppId".
60
68
61
-
- the `ClientID` value with the *Application ID* from the application you registered in Application Registration portal,
62
-
- the `TenantId` by `common`, as here you chose to sign-in users with their work or school or personal account. In case you want to sign-in different audiences, refer back to the first phase of the tutorial
63
-
- and the `ClientSecret` by the client secret you generated in Step 1.
69
+
1. Open the `appsettings.json` file
70
+
1. Find the app key `ClientId` and replace the existing value with the application ID (clientId) of the `WebApp-OpenIDConnect-DotNet-code-v2` application copied from the Azure portal.
71
+
1. Find the app key `TenantId` and replace by `common`, as here you chose to sign-in users with their work or school or personal account. In case you want to sign-in different audiences, refer back to the first phase of the tutorial.
72
+
1. Find the app key `Domain` and replace the existing value with your Azure AD tenant name.
73
+
1. Find the app key `ClientSecret` and replace the existing value with the key you saved during the creation of the `WebApp-OpenIDConnect-DotNet-code-v2` app, in the Azure portal.
64
74
65
75
- In case you want to deploy your app in Sovereign or national clouds, ensure the `GraphApiUrl` option matches the one you want. By default this is Microsoft Graph in the Azure public cloud
0 commit comments