c# - IdentityServer4 500 内部错误,使用授权端点时缺少 EpochTimeExtensions
问题描述
我正在使用 ASP.NET 为 xamarin 表单应用程序创建一个 wep api 后端,我正在使用 identityserver4 进行身份验证和授权。我想使用授权代码工作流,但是当我尝试启动授权/身份验证请求时遇到问题。
我收到的错误是:System.TypeLoadException:无法从程序集“IdentityModel,Version=4.0.0.0,Culture=neutral,PublicKeyToken=e7877f4675df049f”加载类型“IdentityModel.EpochTimeExtensions”。
我在互联网上的任何地方都没有找到解决此问题的方法。
这是我的 Startup.cs
public class Startup
{
public IConfiguration Configuration { get; }
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
//services.AddAutoMapper();
services.AddDbContext<SqlDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddScoped<IUnitOfWork, UnitOfWork>();
services.AddIdentityServer()
.AddInMemoryIdentityResources(Config.GetResources())
.AddInMemoryApiResources(Config.GetApis())
.AddInMemoryClients(Config.GetClients())
.AddDeveloperSigningCredential();
services.AddControllers()
.AddNewtonsoftJson();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseIdentityServer();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapGet("/", async context =>
{
await context.Response.WriteAsync("Hello World !");
});
});
}
}
这是我的 config.cs:
public class Config
{
public static IEnumerable<ApiResource> GetApis()
{
return new List<ApiResource>
{
new ApiResource("Test", "TestService")
};
}
public static IEnumerable<IdentityResource> GetResources()
{
return new List<IdentityResource>
{
new IdentityResources.OpenId()
};
}
public static IEnumerable<Client> GetClients()
{
return new List<Client>
{
new Client
{
ClientId = "client",
AllowedGrantTypes = GrantTypes.Code,
RequireClientSecret = false,
RequireConsent = false,
AllowedScopes = new List<string>{ "Test" , "openid"},
AllowOfflineAccess = true,
RedirectUris = new List<String> {
"https://localhost:44392/account/test/"
}
}
};
}
}
这是我的请求网址:
https://localhost:44392/connect/authorize?client_id=client&response_type=code&redirect_uri=https://localhost:44392/account/test/&scope=Test openid&nonce=5&state=5
我希望这里有人可以帮助我。提前致谢
解决方案
推荐阅读
- aws-lambda - 无法使用雪花连接器运行 AWS Lambda
- node.js - IBM Cloud Functions / OpenWhisk Slack 包和消息附件
- javascript - 与第二个数组中的对象属性值相比,返回过滤后的数组
- azure-data-factory-2 - Azure Data Factory V2 可以将每 20 秒更新一次的文件从本地复制到 Azure Data Lake 吗?
- html - 如何使未选中的复选框具有粘性
- mysql - 是否可以对 GIT 之类的数据库进行版本控制?
- sql - 带有元素的查询取决于
- sql - 从两个临时表 INSERT INTO
- java - 如何在运行 jar 时使用 ram
- git - 如何在有差异的文件中获取 git diff 输出?