This repository is used with the Explore Microsoft Graph scenarios for ASP.NET Core development learning path on Microsoft Learn. To get started, visit the learning path and select one of the modules.
See the Microsoft Learn learning path mentioned above for full details.
-
Ensure you have .NET 6+ installed on your machine. You can download and install it from the following link:
-
Create a Microsoft 365 developer tenant if you don't already have one:
https://developer.microsoft.com/microsoft-365/dev-program
You can view a video that covers key tips here:
-
Register a new app in Azure Active Directory:
-
Login to the Azure Portal.
-
Select Azure Active Directory.
-
Select
App registrations
in theManage
section. -
Select
New registration
in the toolbar. -
Give the app a name.
-
Select
Accounts in any organizational directory (Any Azure AD directory - Multitenant)
in theSupported account types
. -
In the Redirect URI section select
Web
and enter the following URL: -
After the app registration is created, note the
clientId
value shown (you'll use it later) . -
Click the
Authentication
option on the left. -
Add the following URL into the
Web
section'sRedirect URIs
: -
Add the following URL into the
Front-channel logout URL
section: -
Check the
ID tokens
checkbox. -
Save your changes.
-
Click
Certificates & secrets
and create a new client secret. Ensure that you copy and store the secret somewhere since this is the only time you'll be able to access it. You'll need it in the next step.
-
-
Open a terminal window at the root of the
End
folder and run the following commands, substitutingYOUR_APP_ID
with yourApplication (client) ID
from the Azure portal, andYOUR_APP_SECRET
with the application secret you created.
dotnet user-secrets init
dotnet user-secrets set "AzureAd:ClientId" "YOUR_APP_ID"
dotnet user-secrets set "AzureAd:ClientSecret" "YOUR_APP_SECRET"
-
Run
dotnet restore
-
Run
dotnet build
-
Run
dotnet run
-
Once the app is running, navigate to https://localhost:5001 and login using one of your Microsoft 365 tenant users.
-
Once you're logged in you should see your user name displayed. Click on the menu items at the top to view the user's email, calendar, and files (you may need to add mail messages, calendar events, and files for the user if you don't see any).
NOTE: If you get an SSL certificate error, you can generate a dev certificate for your machine using the following command:
dotnet dev-certs https -t
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Microsoft and any contributors grant you a license to the Microsoft documentation and other content in this repository under the Creative Commons Attribution 4.0 International Public License, see the LICENSE file, and grant you a license to any code in the repository under the MIT License, see the LICENSE-CODE file.
Microsoft, Windows, Microsoft Azure and/or other Microsoft products and services referenced in the documentation may be either trademarks or registered trademarks of Microsoft in the United States and/or other countries. The licenses for this project do not grant you rights to use any Microsoft names, logos, or trademarks. Microsoft's general trademark guidelines can be found at http://go.microsoft.com/fwlink/?LinkID=254653.
Privacy information can be found at https://privacy.microsoft.com
Microsoft and any contributors reserve all other rights, whether under their respective copyrights, patents, or trademarks, whether by implication, estoppel or otherwise.