Search code examples
asp.net-mvcoauth-2.0asp.net-coreasp.net-core-mvcasp.net-identity-2

Where to specify the appId and appSecret for Facebook login?


Every time there is a new version of .NET Framework, the framework for authentication using external logins is overhauled!

The external login documentation link for MVC 6, http://go.microsoft.com/fwlink/?LinkID=532715, is missing.

The initialization now uses IApplicationBuilder instead of IAppBuilder in the previous version. The useFacebookAuthentication method now does not take appId and appSecret parameters. How do I specify these?


Solution

  • In your project.json file, in the dependencies section:

    "Microsoft.AspNet.Authentication.Facebook": "1.0.0-rc1-final"
    

    Then, in Startup.cs:

    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    {
        // Other code here
    
        app.UseFacebookAuthentication(options =>
        {
            options.AppId = "";
            options.AppSecret = "";
        });
    
        app.UseMvc();
    }