【发布时间】:2017-07-20 13:13:35
【问题描述】:
我正在开发一个 ASP.NET Core 应用程序,其中用户必须使用单独的数据库帐户。在所有教程中都明确指出,我必须在创建项目时选择“无身份验证”。我不明白为什么。
我想让用户能够使用 LinkedIn 登录,然后获取他们的邮件、姓名和其他信息。我可以通过:
app.UseLinkedInAuthentication(AuthenticationSettings.LinkedInOptions(
Configuration["LinkedIn:ClientId"],
Configuration["LinkedIn:ClientSecret"]));
在 Startup.cs 和(以及文档中的所有其他步骤)中
var loginProviders = SignInManager.GetExternalAuthenticationSchemes().ToList();
if (loginProviders.Count == 0)
{
<div>
<p>
There are no external authentication services configured. See <a href="https://go.microsoft.com/fwlink/?LinkID=532715">this article</a>
for details on setting up this ASP.NET application to support logging in via external services.
</p>
</div>
}
else
{
<form asp-controller="Account" asp-action="ExternalLogin" asp-route-returnurl="@ViewData["ReturnUrl"]" method="post" class="form-horizontal">
<div>
<p>
@foreach (var provider in loginProviders)
{
<button type="submit" class="btn btn-default" name="provider" value="@provider.AuthenticationScheme" title="Log in using your @provider.DisplayName account">@provider.AuthenticationScheme</button>
}
</p>
</div>
</form>
}
在_Layout.cshtml中:
我得到了按钮,用户被要求授予应用程序的权限,我得到了个人数据,但我怎样才能得到其他信息(技能、教育、职位等),例如:
How to Retrieve all possible information about a LinkedIn Account ? (API using C#)
但是没有 OAuth 或者我如何在创建项目时选择授权来实现 OAuth?
【问题讨论】: