From e9ee05a522addde55f39d3d8e4e92bdeb5a2bfd6 Mon Sep 17 00:00:00 2001 From: Scott Addie Date: Mon, 25 Sep 2017 12:46:19 -0500 Subject: [PATCH] Add note regarding AddAuthentication and AddIdentity --- .../security/authentication/social/microsoft-logins.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/aspnetcore/security/authentication/social/microsoft-logins.md b/aspnetcore/security/authentication/social/microsoft-logins.md index 565cc831b3..6a13caf910 100644 --- a/aspnetcore/security/authentication/social/microsoft-logins.md +++ b/aspnetcore/security/authentication/social/microsoft-logins.md @@ -78,6 +78,10 @@ The project template used in this tutorial ensures that [Microsoft.AspNetCore.Au Add the Microsoft Account service in the `ConfigureServices` method in *Startup.cs* file: ```csharp +services.AddIdentity() + .AddEntityFrameworkStores() + .AddDefaultTokenProviders(); + services.AddAuthentication().AddMicrosoftAccount(microsoftOptions => { microsoftOptions.ClientId = Configuration["Authentication:Microsoft:ApplicationId"]; @@ -85,6 +89,8 @@ services.AddAuthentication().AddMicrosoftAccount(microsoftOptions => }); ``` +**Note:** The call to `AddIdentity` configures the default settings. The `AddAuthentication(string defaultScheme)` overload sets the `DefaultScheme` property; and, the `AddAuthentication(Action configureOptions)` overload sets only the properties you explicitly set. Either of these overloads should only be called once when adding multiple authentication providers. Subsequent calls to it have the potential of overriding any previously configured [AuthenticationOptions](https://docs.microsoft.com/aspnet/core/api/microsoft.aspnetcore.builder.authenticationoptions) properties. + # [ASP.NET Core 1.x](#tab/aspnetcore1x) Add the Microsoft Account middleware in the `Configure` method in *Startup.cs* file: