简体   繁体   中英

Asp.net 5 MVC6 - Using owin for facebook login

i'm using asp.net 5 with mvc6 (beta), and i want to use microsoft owin to allow my users to login with their facebook account. In Startup.cs i'm unable to do 'app.UseFacebookAuthentication' after installed Microsoft.Owin.Security.Facebook package from NuGet.

Is there a tutorial about it? is it possibile to use claims with MVC6?

Thank you.

Set up Facebook app : Sign in at https://developers.facebook.com/apps and create a new app for web sites. Skip the quick start. Take note of the App id and app secret. Go to settings and paste your website address. Push “Add platform”, and choose website.

Install SecretManager tool : Install SecretManager tool by running this command in your app folder:

dnu commands install Microsoft.Extensions.SecretManager

Run commands to store AppId and AppSecret:

user-secret set Authentication:Facebook:AppId 123123
user-secret set Authentication:Facebook:AppSecret 456456

Add dependencies to project.json :

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

Add lines to startup.cs in the Configure part

  // Use Facebook authentication ( see http://go.microsoft.com/fwlink/?LinkID=532715 ).
        app.UseFacebookAuthentication(options =>
        {
            options.AppId = Configuration["Authentication:Facebook:AppId"];
            options.AppSecret = Configuration["Authentication:Facebook:AppSecret"];
        });

Read more in this tutorial which shows you how to build an ASP.NET 5 Web application that enables users to log in using OAuth 2.0 with credentials from an external authentication provider, such as Facebook, Twitter, LinkedIn, Microsoft, or Google. http://aspnetmvc.readthedocs.org/en/latest/security/sociallogins.html

ASP.net 5 ( MVC 6) still available as preview edition. Also they have changed some major changes so Owin the way it support in ASP.net MVC 5 will not support same way. As they have changed basic interface that support that functionality but today I came across article they provide information how can we use old Owin and integrate in ASP.net MVC 6.

http://blogs.msdn.com/b/webdev/archive/2014/11/14/katana-asp-net-5-and-bridging-the-gap.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM