"
 
 
 
ASP.NET (snapshot 2017) Microsoft documentation and samples

Configuring Microsoft Account authentication

By Valeriy Novytskyy and Rick Anderson

This tutorial shows you how to enable your users to sign in with their Microsoft account using a sample ASP.NET Core 2.0 project created on the previous page.

Create the app in Microsoft Developer Portal

Sign in dialog
Sign in dialog

If you don’t already have a Microsoft account, tap Create one! After signing in you are redirected to My applications page:

Microsoft Developer Portal open in Microsoft Edge
Microsoft Developer Portal open in Microsoft Edge
New Application Registration dialog
New Application Registration dialog
Registration page
Registration page
Add Platform dialog
Add Platform dialog
Web Platform section
Web Platform section

Store Microsoft Application Id and Password

New password generated dialog
New password generated dialog

Link sensitive settings like Microsoft Application ID and Password to your application configuration using the Secret Manager. For the purposes of this tutorial, name the tokens Authentication:Microsoft:ApplicationId and Authentication:Microsoft:Password.

Configure Microsoft Account Authentication

The project template used in this tutorial ensures that Microsoft.AspNetCore.Authentication.MicrosoftAccount package is already installed.

ASP.NET Core 2.x

Add the Microsoft Account service in the ConfigureServices method in Startup.cs file:

[!INCLUDEdefault settings configuration]

ASP.NET Core 1.x

Add the Microsoft Account middleware in the Configure method in Startup.cs file:


Although the terminology used on Microsoft Developer Portal names these tokens ApplicationId and Password, they are exposed as ClientId and ClientSecret to the configuration API.

See the MicrosoftAccountOptions API reference for more information on configuration options supported by Microsoft Account authentication. This can be used to request different information about the user.

Sign in with Microsoft Account

Run your application and click Log in. An option to sign in with Microsoft appears:

Web application Log in page: User not authenticated
Web application Log in page: User not authenticated

When you click on Microsoft, you are redirected to Microsoft for authentication. After signing in with your Microsoft Account (if not already signed in) you will be prompted to let the app access your info:

Microsoft authentication dialog
Microsoft authentication dialog

Tap Yes and you will be redirected back to the web site where you can set your email.

You are now logged in using your Microsoft credentials:

Web application: User authenticated
Web application: User authenticated

Troubleshooting

Next steps





Comments ( )
<00>  <01>  <02>  <03>  <04>  <05>  <06>  <07>  <08>  <09>  <10>  <11>  <12>  <13>  <14>  <15>  <16>  <17>  <18>  <19>  <20>  <21>  <22>  <23
Link to this page: //www.vb-net.com/AspNet-DocAndSamples-2017/aspnetcore/security/authentication/social/microsoft-logins.htm
<SITEMAP>  <MVC>  <ASP>  <NET>  <DATA>  <KIOSK>  <FLEX>  <SQL>  <NOTES>  <LINUX>  <MONO>  <FREEWARE>  <DOCS>  <ENG>  <CHAT ME>  <ABOUT ME>  < THANKS ME>