gpt4 book ai didi

c# - 如何使用 .NET 4.5 Owin 对 LinkedIn 进行身份验证

转载 作者:行者123 更新时间:2023-11-30 16:59:53 30 4
gpt4 key购买 nike

.NET 4.5 现在有这些不同的身份验证方法,但我没有看到适用于 LinkedIn 的方法。有谁知道 .NET 4.5 是否具有通过 LinkedIn 进行 oAuth 的内置方式?

using Microsoft.AspNet.Identity;
using Microsoft.Owin;
using Microsoft.Owin.Security.Cookies;
using Owin;

namespace WebPageStarterKit
{
public partial class Startup {

// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301883
public void ConfigureAuth(IAppBuilder app)
{
// Enable the application to use a cookie to store information for the signed in user
// and also store information about a user logging in with a third party login provider.
// This is required if your application allows users to login
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login")
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

// Uncomment the following lines to enable logging in with third party login providers
//app.UseMicrosoftAccountAuthentication(
// clientId: "",
// clientSecret: "");

//app.UseTwitterAuthentication(
// consumerKey: "",
// consumerSecret: "");


//app.UseFacebookAuthentication(
// appId: "",
// appSecret: "");

//app.UseGoogleAuthentication();
}
}
}

最佳答案

我不确定“内置”...但您可以使用 nuget 获取另一个 OWIN 包。

查看此网站 Introducing the Yahoo and LinkedIn OAuth security providers for OWIN一个非常简单的教程。

简而言之:

  1. 使用 nuget 安装这个包:Owin.Security.Providers
  2. LinkedIn Developers 注册 LinkedIn 开发者帐户
  3. 请求 API key 。填写完表格后记下API key 和Secret Key
  4. 编辑您的 App_Start\Startup.Auth.cs 文件以包含“使用 Owin.Security.Providers.Linkedin”
  5. 在该文件的底部,为 LinkedIn 添加一个部分:

        app.UseLinkedInAuthentication(new LinkedInAuthenticationOptions() 
    {
    ClientId = "API Key",
    ClientSecret = "Secret Key",
    });

关于c# - 如何使用 .NET 4.5 Owin 对 LinkedIn 进行身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23045081/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com