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
{{ message }}
This repository was archived by the owner on Apr 12, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+38-30Lines changed: 38 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ The sample uses only delegate permissions, therefore it does not require admin c
18
18
19
19
## Using the Microsoft Graph Connect Sample
20
20
21
-
The screenshot below shows the app's start page.
21
+
The screenshot below shows the app's start page.
22
22
23
23

24
24
@@ -30,9 +30,9 @@ This library is suitable for use in a production environment. We provide the sam
30
30
31
31
To use the Microsoft Graph Connect Sample for ASP.NET Core 2.0, you need the following:
32
32
33
-
- Visual Studio 2017 [with .NET Core 2.0 SDK](https://www.microsoft.com/net/download/core) installed on your development computer.
34
-
- Either a [personal Microsoft account](https://signup.live.com) or a [work or school account](https://dev.office.com/devprogram). (You don't need to be an administrator of the tenant.)
35
-
- The application ID and key from the application that you [register on the App Registration Portal](#register-the-app).
33
+
* Visual Studio 2017 [with .NET Core 2.0 SDK](https://www.microsoft.com/net/download/core) installed on your development computer.
34
+
* Either a [personal Microsoft account](https://signup.live.com) or a [work or school account](https://dev.office.com/devprogram). (You don't need to be an administrator of the tenant.)
35
+
* The application ID and key from the application that you [register on the App Registration Portal](#register-the-app).
36
36
37
37
## Register the app
38
38
@@ -64,26 +64,28 @@ This app uses the Azure AD v2.0 endpoint, so you'll register it on the [App Regi
64
64
65
65
h. Click **Save**.
66
66
67
-
4. Configure Permissions for your application:
67
+
>You'll use the application ID and secret to configure the app in Visual Studio.
68
+
69
+
4. Configure Permissions for your application. **(Optional)**
70
+
71
+
>Note that we are not required to add permissions for reading user data and sending emails during the app registration as you would do with the [v1 endpoint (ADAL)](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-integrating-applications). The [Incremental and dynamic consent](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-compare#incremental-and-dynamic-consent) capability of the v2 endpoint (MSAL) has made this step optional.
68
72
69
73
a. Choose **Microsoft Graph Permissions** > **Delegated Permissions** > **Add**.
70
74
71
75
b. Select **openid**, **email**, **profile**, **offline_access**, **User.Read**, **User.ReadBasic.All** and **Mail.Send**. Then click **Ok**.
72
76
73
77
c. Click **Save**.
74
78
75
-
You'll use the application ID and secret to configure the app in Visual Studio.
76
-
77
79
## Configure and run the sample
78
80
79
81
1. Download or clone the Microsoft Graph Connect Sample for ASP.NET Core.
80
82
81
-
2. Open the **MicrosoftGraphAspNetCoreConnectSample.sln** sample file in Visual Studio 2017.
83
+
2. Open the **MicrosoftGraphAspNetCoreConnectSample.sln** sample file in Visual Studio 2017.
82
84
83
85
3. In Solution Explorer, open the **appsettings.json** file in the root directory of the project.
84
86
85
87
a. For the **AppId** key, replace `ENTER_YOUR_APP_ID` with the application ID of your registered application.
86
-
88
+
87
89
b. For the **AppSecret** key, replace `ENTER_YOUR_SECRET` with the password of your registered application. Note that in production apps you should always use certificates as your application secrets, but for this sample we will use a simple shared secret password.
88
90
89
91
4. Press F5 to build and run the sample. This will restore NuGet package dependencies and open the app.
@@ -98,29 +100,34 @@ You'll use the application ID and secret to configure the app in Visual Studio.
98
100
99
101
8. Optionally edit the recipient list, and then choose the **Send email** button. When the mail is sent, a Success message is displayed on the top of the page.
100
102
101
-
## Key components of the sample
103
+
## Key components of the sample
104
+
102
105
The following files contain code that's related to connecting to Microsoft Graph, loading user data and sending emails.
103
106
104
-
-[`appsettings.json`](MicrosoftGraphAspNetCoreConnectSample/appsettings.json) Contains values used for authentication and authorization.
105
-
-[`Startup.cs`](MicrosoftGraphAspNetCoreConnectSample/Startup.cs) Configures the app and the services it uses, including authentication.
107
+
*[`appsettings.json`](MicrosoftGraphAspNetCoreConnectSample/appsettings.json) Contains values used for authentication and authorization.
108
+
*[`Startup.cs`](MicrosoftGraphAspNetCoreConnectSample/Startup.cs) Configures the app and the services it uses, including authentication.
106
109
107
-
**Controllers**
108
-
-[`AccountController.cs`](MicrosoftGraphAspNetCoreConnectSample/Controllers/AccountController.cs) Handles sign in and sign out.
109
-
-[`HomeController.cs`](MicrosoftGraphAspNetCoreConnectSample/Controllers/HomeController.cs) Handles the requests from the UI.
110
+
### Controllers
110
111
111
-
**Views**
112
-
-[`Index.cshtml`](MicrosoftGraphAspNetCoreConnectSample/Views/Home/Index.cshtml) Contains the sample's UI.
112
+
*[`AccountController.cs`](MicrosoftGraphAspNetCoreConnectSample/Controllers/AccountController.cs) Handles sign in and sign out.
113
+
*[`HomeController.cs`](MicrosoftGraphAspNetCoreConnectSample/Controllers/HomeController.cs) Handles the requests from the UI.
113
114
114
-
**Helpers**
115
-
-[`GraphAuthProvider.cs`](MicrosoftGraphAspNetCoreConnectSample/Helpers/GraphAuthProvider.cs) Gets an access token using MSAL's **AcquireTokenSilentAsync** method.
116
-
-[`GraphSdkHelper.cs`](MicrosoftGraphAspNetCoreConnectSample/Helpers/GraphSDKHelper.cs) Initiates the SDK client used to interact with Microsoft Graph.
117
-
-[`GraphService.cs`](MicrosoftGraphAspNetCoreConnectSample/Helpers/GraphService.cs) Contains methods that use the **GraphServiceClient** to build and send calls to the Microsoft Graph service and to process the response.
118
-
- The **GetUserJson** action gets the user's profile by an email adress and converts it to JSON.
119
-
- The **GetPictureBase64** action gets the user's profile picture and converts it to a base64 string.
120
-
- The **SendEmail** action sends an email on behalf of the current user.
115
+
### Views
121
116
122
-
**TokenStorage**
123
-
-[`SessionTokenCache.cs`](MicrosoftGraphAspNetCoreConnectSample/Helpers/SessionTokenCache.cs) Sample implementation of an in-memory token cache. Production apps will typically use some method of persistent storage.
117
+
*[`Index.cshtml`](MicrosoftGraphAspNetCoreConnectSample/Views/Home/Index.cshtml) Contains the sample's UI.
118
+
119
+
### Helpers
120
+
121
+
*[`GraphAuthProvider.cs`](MicrosoftGraphAspNetCoreConnectSample/Helpers/GraphAuthProvider.cs) Gets an access token using MSAL's **AcquireTokenSilentAsync** method.
122
+
*[`GraphSdkHelper.cs`](MicrosoftGraphAspNetCoreConnectSample/Helpers/GraphSDKHelper.cs) Initiates the SDK client used to interact with Microsoft Graph.
123
+
*[`GraphService.cs`](MicrosoftGraphAspNetCoreConnectSample/Helpers/GraphService.cs) Contains methods that use the **GraphServiceClient** to build and send calls to the Microsoft Graph service and to process the response.
124
+
* The **GetUserJson** action gets the user's profile by an email adress and converts it to JSON.
125
+
* The **GetPictureBase64** action gets the user's profile picture and converts it to a base64 string.
126
+
* The **SendEmail** action sends an email on behalf of the current user.
127
+
128
+
### TokenStorage
129
+
130
+
*[`SessionTokenCache.cs`](MicrosoftGraphAspNetCoreConnectSample/Helpers/SessionTokenCache.cs) Sample implementation of an in-memory token cache. Production apps will typically use some method of persistent storage.
124
131
125
132
## Contributing
126
133
@@ -138,10 +145,11 @@ You can suggest changes for Microsoft Graph on [UserVoice](https://officespdev.u
0 commit comments