asp.net-core - asp .net core 3.1 身份服务器
问题描述
我有一个需要在 .net core 3.1 更新的项目。问题是我不知道如何使用 3.1 中的这个新功能。我在 appsettings.development.json 中有我的身份服务器设置,如下所示:
"IdentityServerSettings": {
"TokenUrl": "https://esample/token",
"ClientId": "xxxxx-xxxxx-xxxxx-xxxxx-xxxxxxxxxx",
"ClientSecret": "yyyyy-yyyyy-yyyyy-yyyyy-yyyyyyyyy",
"GrantType": "credentials",
"Scope": "scope"
}
这是 Startup.cs:
public void ConfigureServices(IServiceCollection services)
{
var identityServerSettingsSection = this.Configuration.GetSection("IdentityServerSettings");
services.AddIdentityServer()
// here i need to app those properties from json
}
这是我从 json 文件中读取它们的方法
identityServerSettingsSection.GetValue<string>("ClientId")
提前致谢!
解决方案
你可以像这样添加身份服务器
services.AddIdentityServer(Configuration);
哪个配置是 IConfiguration。对于 appsetting.json,请遵循此IdentityServer 选项
推荐阅读
- python - 如何在不使用事件的情况下使用 Discord.py 发表评论?
- r - 编写自定义函数时将列名传递给 dplyr::coalesce()
- java - 如何在 Java 中将每个标签与其 Textfield 旁边的对齐?
- python - AttributeError:模块“asyncio.coroutines”没有属性“_is_coroutine”
- ios - Core Data 使用 Canvas 预览的要求是什么 - SwiftUI
- c# - Newtonsoft.Json - 反序列化自定义类型时抛出 DeserializeObject:将值“somestring”转换为类型 CustomType 时出错
- sql - 在数据库“天气”上执行 SQL 查询时出错:“(”附近:语法错误
- c# - .NET Core/5 IConfiguration 在 Raspberry Pi 4 4GB 上的 Ubuntu 20.10 x64 上不起作用
- c# - 如何使用 C# 在 Excel 上定位特定工作表
- c# - 无法加载文件或程序集 Microsoft.Extensions.DependencyInjection.Abstractions,版本 = 5.0.0.0