实现OpenIdDict身份验证后端(Asp.Net核心),以便能够通过模型实体和LinkedIn身份进行身份验证

时间:2019-09-23 08:47:32

标签: asp.net-core openid-connect linkedin-api openiddict

目标是能够通过以下方式登录移动应用(本机反应):

  • 在应用username and password
  • "Login with LinkedId"功能。

我对此主题进行了很多研究,并阅读了KévinChalet的(@Pinpoint)博客系列,还从https://github.com/openiddict/openiddict-samples

中克隆了这些样本。

我已经创建了测试服务器应用:https://github.com/Jamaxack/OpenIdConnectAuthLinkedIn

我可以使用https://oidcdebugger.com测试对LinkedIn的授权,但是现在,我很困惑。没有https://oidcdebugger.com,我如何测试LinkedIn授权?例如邮递员?就我而言,我应该使用哪种Auth流程?

 options.AllowImplicitFlow()
        .AllowPasswordFlow()
        .AllowAuthorizationCodeFlow()
        .AllowRefreshTokenFlow();

谢谢。

1 个答案:

答案 0 :(得分:0)

您可以使用Authorization Code Flow通过Linkedin登录并向会员申请权限。

如果使用Postman,则可以尝试以下步骤:

  1. 添加新请求,单击Authorization,选择OAuth 2.0作为TYPE,然后将Add authorization data to设置为Request Headers。如果要检查Postman生成的授权标头和参数,请单击“预览请求”按钮。

  2. 单击Get New Access Token按钮。输入正确的回调URL,身份验证URL,令牌URL,客户ID,客户机密和范围,回调URL应与linkedin应用程序门户中的一个寄存器匹配。

    enter image description here

  3. 现在,您现在应该会看到一个屏幕,提示您登录到LinkedIn帐户。在“应用程序授权确认”页面中单击Allow之后,您将在Postman中获得令牌。

  4. 使用令牌作为授权承载令牌标头向api Get发起https://api.linkedin.com/v2/me请求,您将从linkedin API端点获得正确的响应。