简体   繁体   English

Asp.net 5 MVC6 - 使用owin登录facebook

[英]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. 我正在使用带有mvc6(beta)的asp.net 5,我想使用microsoft owin允许我的用户使用他们的Facebook帐户登录。 In Startup.cs i'm unable to do 'app.UseFacebookAuthentication' after installed Microsoft.Owin.Security.Facebook package from NuGet. 在Startup.cs中,我无法在从NuGet安装Microsoft.Owin.Security.Facebook包之后执行'app.UseFacebookAuthentication'。

Is there a tutorial about it? 有关于它的教程吗? is it possibile to use claims with MVC6? 是否可以在MVC6中使用声明?

Thank you. 谢谢。

Set up Facebook app : Sign in at https://developers.facebook.com/apps and create a new app for web sites. 设置Facebook应用程序 :登录https://developers.facebook.com/apps并为网站创建一个新应用程序。 Skip the quick start. 跳过快速入门。 Take note of the App id and app secret. 记下App id和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: 安装SecretManager工具 :通过在app文件夹中运行此命令来安装SecretManager工具:

dnu commands install Microsoft.Extensions.SecretManager

Run commands to store AppId and AppSecret: 运行命令来存储AppId和AppSecret:

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

Add dependencies to project.json : 向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 在Configure部分中向startup.cs添加行

  // 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. 阅读本教程中的更多内容,该教程向您展示如何构建ASP.NET 5 Web应用程序,使用户能够使用OAuth 2.0使用来自外部身份验证提供程序(如Facebook,Twitter,LinkedIn,Microsoft或Google)的凭据登录。 http://aspnetmvc.readthedocs.org/en/latest/security/sociallogins.html http://aspnetmvc.readthedocs.org/en/latest/security/sociallogins.html

ASP.net 5 ( MVC 6) still available as preview edition. ASP.net 5(MVC 6)仍然可用作预览版。 Also they have changed some major changes so Owin the way it support in ASP.net MVC 5 will not support same way. 此外,他们已经改变了一些重大变化,因此Owin在ASP.net MVC 5中支持的方式不会支持相同的方式。 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. 因为他们已经改变了支持该功能的基本界面,但今天我遇到了他们提供的信息,我们如何使用旧的Owin并集成在ASP.net MVC 6中。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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