我如何像LinkedIn
自定义身份验证提供者从出现在SignInManager.GetExternalAuthenticationSchemes()
其中Login.cshtml
拍摄由默认如何LinkedIn添加到SignInManager.GetExternalAuthenticationSchemes()
背景细节:
我试图理解asp.net核心身份框架。在这一努力中,我创建了一个标准的.NET核心项目
我尝试了支持Google
认证一起阅读documentation,这一切对我来说工作得很好。
我能够为我做LinkedIn
验证工作,但无法理解如何使某些部分工作。要添加LinkedIn
验证支持,我进行了如下修改
添加了下面线在Startup.Configure
方法
app.UseOAuthAuthentication(new OAuthOptions() {
AuthenticationScheme = "LinkedIn",
ClientId = Configuration["Authentication:LinkedIn:ClientID"],
ClientSecret = Configuration["Authentication:LinkedIn:ClientSecret"],
CallbackPath = new PathString("/signin-linkedin"),
AuthorizationEndpoint = "https://www.linkedin.com/oauth/v2/authorization",
TokenEndpoint = "https://www.linkedin.com/oauth/v2/accessToken",
UserInformationEndpoint = "https://api.linkedin.com/v1/people/~:(id,formatted-name,email-address,picture-url)",
Scope = { "r_basicprofile", "r_emailaddress" },
});
添加了必需的ClientId
和ClientSecret
到配置
增加了以下行到Login.cshtml
<button type="submit" class="btn btn-default" name="provider" value="LinkedIn" title="Log in using your LinkedIn account">LinkedIn</button>
所有这些工作很好。现在的问题是:
对于支持的认证供应商,当我打电话,说,app.UseGoogleAuthentication
在Startup.Configure
,我在Login.cshtml
列表Google
为提供呼叫SignInManager.GetExternalAuthenticationSchemes()
。什么我需要做的,所以调用SignInManager.GetExternalAuthenticationSchemes()
还将列出LinkedIn
作为提供
我相信你已经签出https://auth0.com/blog/authenticating-a-user-with-linkedin-in-aspnet - 核心/? –
@GeoffJames是的,我做到了。它帮助我理解了一堆事情,但不是这个具体问题。没有正式的“asp.net核心”框架文档和类似“身份证”的相关图书馆一直是我最大的敌人 – Vikhram
我想你可能有。只是想我会检查。我同意,这个话题似乎没有太多。只有通常的“如何添加auth提供商...”的东西。我希望你的问题排序:)快乐的编码! –