Skip to content
This repository was archived by the owner on Oct 3, 2024. It is now read-only.

Commit 7166ae4

Browse files
authored
Merge pull request #30 from irvinesunday/master
Libraries and Markdown updates for Webhooks-Rest sample
2 parents 7d4d685 + 738b398 commit 7166ae4

14 files changed

+60
-19
lines changed

GraphWebhooks/GraphWebhooks.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@
6363
<HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
6464
</Reference>
6565
<Reference Include="Microsoft.CSharp" />
66-
<Reference Include="Microsoft.Graph, Version=1.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
67-
<HintPath>..\packages\Microsoft.Graph.1.9.0\lib\net45\Microsoft.Graph.dll</HintPath>
66+
<Reference Include="Microsoft.Graph, Version=1.12.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
67+
<HintPath>..\packages\Microsoft.Graph.1.12.0\lib\net45\Microsoft.Graph.dll</HintPath>
6868
</Reference>
69-
<Reference Include="Microsoft.Graph.Core, Version=1.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
70-
<HintPath>..\packages\Microsoft.Graph.Core.1.9.0\lib\net45\Microsoft.Graph.Core.dll</HintPath>
69+
<Reference Include="Microsoft.Graph.Core, Version=1.12.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
70+
<HintPath>..\packages\Microsoft.Graph.Core.1.12.0\lib\net45\Microsoft.Graph.Core.dll</HintPath>
7171
</Reference>
72-
<Reference Include="Microsoft.Identity.Client, Version=1.1.2.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae, processorArchitecture=MSIL">
73-
<HintPath>..\packages\Microsoft.Identity.Client.1.1.2-preview0008\lib\net45\Microsoft.Identity.Client.dll</HintPath>
72+
<Reference Include="Microsoft.Identity.Client, Version=2.7.1.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae, processorArchitecture=MSIL">
73+
<HintPath>..\packages\Microsoft.Identity.Client.2.7.1\lib\net45\Microsoft.Identity.Client.dll</HintPath>
7474
</Reference>
7575
<Reference Include="Microsoft.IdentityModel.Protocol.Extensions, Version=1.0.40306.1554, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7676
<HintPath>..\packages\Microsoft.IdentityModel.Protocol.Extensions.1.0.4.403061554\lib\net45\Microsoft.IdentityModel.Protocol.Extensions.dll</HintPath>

GraphWebhooks/Helpers/GraphHelper.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ public static GraphServiceClient GetAuthenticatedClient(string userId, string re
2424
var cca = new ConfidentialClientApplication(Startup.ClientId, redirect,
2525
new ClientCredential(Startup.ClientSecret), tokenCache.GetMsalCacheInstance(), null);
2626

27-
var authResult = await cca.AcquireTokenSilentAsync(Startup.Scopes, cca.Users.First());
27+
var accounts = await cca.GetAccountsAsync();
28+
var authResult = await cca.AcquireTokenSilentAsync(Startup.Scopes, accounts.First());
2829
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", authResult.AccessToken);
2930
}));
3031

GraphWebhooks/packages.config

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net461" />
1414
<package id="Microsoft.AspNet.WebPages" version="3.2.6" targetFramework="net461" />
1515
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.8" targetFramework="net461" />
16-
<package id="Microsoft.Graph" version="1.9.0" targetFramework="net461" />
17-
<package id="Microsoft.Graph.Core" version="1.9.0" targetFramework="net461" />
18-
<package id="Microsoft.Identity.Client" version="1.1.2-preview0008" targetFramework="net461" />
16+
<package id="Microsoft.Graph" version="1.12.0" targetFramework="net461" />
17+
<package id="Microsoft.Graph.Core" version="1.12.0" targetFramework="net461" />
18+
<package id="Microsoft.Identity.Client" version="2.7.1" targetFramework="net461" />
1919
<package id="Microsoft.IdentityModel.Protocol.Extensions" version="1.0.4.403061554" targetFramework="net461" />
2020
<package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.9" targetFramework="net461" />
2121
<package id="Microsoft.Net.Compilers" version="2.8.0" targetFramework="net461" developmentDependency="true" />

README.md

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,57 @@ To use the Microsoft Graph ASP.NET Webhooks sample, you need the following:
3232
- A public HTTPS endpoint to receive and send HTTP requests. You can host this on Microsoft Azure or another service, or you can [use ngrok](#set-up-the-ngrok-proxy-optional) or a similar tool while testing.
3333

3434
### Register the app
35+
In this exercise, you will create a new Azure AD web application registration using the Azure Active Directory admin center.
3536

36-
This app uses the Azure AD v2 endpoint, so you'll register it in the [Application Registration Portal](https://apps.dev.microsoft.com).
37+
1. Determine your ASP.NET app's URL. In Visual Studio's Solution Explorer, select the **GraphWebhooks** project. In the **Properties** window, find the value of **SSL URL**. Copy this value.
3738

38-
1. Sign in to the portal with either your Microsoft account, or your work or school account.
39-
1. Choose **Add an app**.
40-
1. Enter a friendly name for the application and choose **Create application**.
41-
1. Locate the **Application Secrets** section and choose **Generate New Password**. Copy the password now and save it to a safe place. Once you've copied the password, click **Ok**.
42-
1. Locate the **Platforms** section, and choose **Add Platform**. Choose **Web**, then enter `https://localhost:44300` under **Redirect URIs**.
43-
1. Choose **Save** at the bottom of the page.
39+
![Screenshot of the Visual Studio Properties window](readme-images/vs-project-url.PNG)
40+
41+
1. Open a browser and navigate to the [Azure Active Directory admin center](https://aad.portal.azure.com). Login using a **Work or School Account**.
42+
43+
1. Select **Azure Active Directory** in the left-hand navigation, then select **App registrations (Preview)** under **Manage**.
44+
45+
![A screenshot of the App registrations ](readme-images/aad-portal-app-registrations.png)
46+
47+
1. Select **New registration**. On the **Register an application** page, set the values as follows.
48+
49+
- Set a preferred **Name** e.g. `GraphWebhooks Sample`.
50+
- Set **Supported account types** to **Accounts in any organizational directory**.
51+
- Under **Redirect URI**, set the first drop-down to `Web` and set the value to the ASP.NET app SSL URL you copied in step 1.
52+
53+
![A screenshot of the Register an application page](readme-images/aad-register-an-app.png)
54+
55+
1. Choose **Register**. On the **GraphWebhooks Sample** page, copy the value of the **Application (client) ID** and save it, you will need it in the next step.
56+
57+
![A screenshot of the application ID of the new app registration](readme-images/aad-application-id.PNG)
58+
59+
1. Select **Authentication** under **Manage**. Locate the **Implicit grant** section and enable **ID tokens**. Choose **Save**.
60+
61+
![A screenshot of the Implicit grant section](readme-images/aad-implicit-grant.png)
62+
63+
1. Select **Certificates & secrets** under **Manage**. Select the **New client secret** button. Enter a value in **Description** and select one of the options for **Expires** and choose **Add**.
64+
65+
![A screenshot of the Add a client secret dialog](readme-images/aad-new-client-secret.png)
66+
67+
1. Copy the client secret value before you leave this page. You will need it in the next step.
68+
69+
> [!IMPORTANT]
70+
> This client secret is never shown again, so make sure you copy it now.
71+
72+
![A screenshot of the newly added client secret](readme-images/aad-copy-client-secret.png)
73+
74+
1. From the **Manage** page, select **API permissions** > **Add a permission**.
75+
76+
![A screenshot of Select API Permissions](readme-images/aad-api-permissions.PNG)
77+
78+
1. Choose **Microsoft API** > **Microsoft Graph**.
79+
80+
![A screenshot of Request API permissions](readme-images/aad-request-api-permissions.PNG)
81+
82+
1. Choose **Delegated permissions**. In the search box, type **Mail.Read** and select the first option from the list. Select **Add permissions**.
83+
84+
![A screenshot of Delegated permissions](readme-images/aad-delegated-permissions.PNG)
4485

45-
You'll use the application ID and secret to configure the app in Visual Studio.
4686

4787
### Set up the ngrok proxy (optional)
4888

@@ -174,4 +214,4 @@ If you have a feature suggestion, please post your idea on our [User Voice](http
174214

175215
## Copyright
176216

177-
Copyright (c) 2017 Microsoft. All rights reserved.
217+
Copyright (c) 2019 Microsoft. All rights reserved.

readme-images/aad-api-permissions.PNG

36.2 KB
Loading

readme-images/aad-application-id.PNG

37.5 KB
Loading
8.42 KB
Loading
37.9 KB
Loading

readme-images/aad-implicit-grant.png

7 KB
Loading
36.2 KB
Loading

0 commit comments

Comments
 (0)