Add note regarding AddAuthentication and AddIdentity

pull/4387/head
Scott Addie 2017-09-25 12:46:19 -05:00
parent fe13f1cf32
commit e9ee05a522
1 changed files with 6 additions and 0 deletions

View File

@ -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<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.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<AuthenticationOptions> 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: