The option "SignInScheme" must be provided.

I am creating an ASP.NET 5 MVC 6 application that will only use Facebook / Google authentication. I am also trying to use cookie middleware without all ASP.NET authentication - following this article: https://docs.asp.net/en/latest/security/authentication/cookie.html

So, I started with a clean application without authentication, and then added the Microsoft.AspNet.Authentication.Cookies and Microsoft.AspNet.Authentication.Facebook NuGet packages to have a very minimalistic approach in which I don't include anything I don't need.

I added the following code to Configure in Startup.cs, but I get the message "SignInScheme option must be provided." Any idea what I am missing?

app.UseCookieAuthentication(options => { options.AuthenticationScheme = "MyCookieMiddlewareInstance"; options.LoginPath = new PathString("/Accounts/Login/"); options.AccessDeniedPath = new PathString("/Error/Unauthorized/"); options.AutomaticAuthenticate = true; options.AutomaticChallenge = true; }); app.UseFacebookAuthentication(options => { options.AppId = "myFacebookAppIdGoesHere"; options.AppSecret = "myFacebookAppSecretGoesHere"; }); 
+6
source share
1 answer

As indicated by the error message, you should set options.SignInScheme in your Facebook middleware settings:

 app.UseFacebookAuthentication(options => { options.AppId = "myFacebookAppIdGoesHere"; options.AppSecret = "myFacebookAppSecretGoesHere"; // This value must correspond to the instance of the cookie // middleware used to create the authentication cookie. options.SignInScheme = "MyCookieMiddlewareInstance"; }); 

In addition, you can also install it globally from ConfigureServices (it will configure each middleware for authentication, so you do not need to install options.SignInScheme ):

 public void ConfigureServices(IServiceCollection services) { services.AddAuthentication(options => { // This value must correspond to the instance of the cookie // middleware used to create the authentication cookie. options.SignInScheme = "MyCookieMiddlewareInstance"; }); } 
+8
source

All Articles