【问题标题】:cant use openiddict with Microsoft.AspNetCore.Authentication.JwtBearer不能将 openiddict 与 Microsoft.AspNetCore.Authentication.JwtBearer 一起使用
【发布时间】:2017-10-23 12:48:29
【问题描述】:

我有 openiddict 示例,但我想改用 JWT。我了解到我不能将 OAuth 与 JWT 一起使用,因为它们是两个不同的东西。有道理。

但是如果我想使用 JWT,那么我需要安装一个不记名令牌中间件包。我相信,对于 .net 核心,是 Microsoft.AspNetCore.Authentication.JwtBearer

但我无法同时使用 openiddict 安装该软件包。是否需要使用特定版本的 JwtBearer 才能使其工作?

我尝试安装时遇到的错误是

Unable to resolve 'OpenIddict (>= 1.0.0)' for '.NETCoreApp,Version=v1.1'.
Unable to resolve 'OpenIddict.Mvc (>= 1.0.0)' for '.NETCoreApp,Version=v1.1'.
Unable to resolve 'OpenIddict.EntityFrameworkCore (>= 1.0.0)' for '.NETCoreApp,Version=v1.1'.

Openiddict 包设置

<!-- OpenIdDict -->
<PackageReference Include="AspNet.Security.OAuth.Validation" Version="1.0.0-*" />
<PackageReference Include="OpenIddict" Version="1.0.0-*" />
<PackageReference Include="OpenIddict.EntityFrameworkCore" Version="1.0.0-*" />
<PackageReference Include="OpenIddict.Mvc" Version="1.0.0-*" />

NuGet 配置

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
    <add key="aspnet-contrib" value="https://www.myget.org/F/aspnet-contrib/api/v3/index.json" />
  </packageSources>
</configuration>

【问题讨论】:

  • 错误指出没有找到 myget 或包本身查看 myget 提要,它们确实在其中,版本为:1.0.0-beta2-0614 他们的目标是应该完全兼容的 .netstandard 1.4。 AspNet.Security.OAuth.Validation 有 1.0.0 绰号,但没有 - 或 * myget.org/gallery/aspnet-contrib 确保您的 Nuget 管理器在过滤器上有 ALL 而不是 Nuget

标签: asp.net-core nuget .net-core jwt openiddict


【解决方案1】:

请尝试在包管理器控制台中运行它:

Install-Package OpenIddict -Version 1.0.0-beta2-0615 -Source https://www.myget.org/F/aspnet-contrib/api/v3/index.json

将此包源添加到 Nuget 包源: https://www.myget.org/F/aspnet-contrib/api/v3/index.json

【讨论】:

    猜你喜欢
    • 2017-06-20
    • 1970-01-01
    • 2019-02-20
    • 2014-06-20
    • 2020-03-06
    • 2019-09-01
    • 2017-04-15
    • 2019-07-09
    • 1970-01-01
    相关资源
    最近更新 更多