我试图搜索该问题的解决方案,但没有找到正确的搜索文本。
我的问题是,如何配置我的IdentityServer,使其也可以接受/授权带有BearerTokens的Api请求?
我已配置并正在运行IdentityServer4。我还在我的IdentityServer上配置了测试API,如下所示:
[Authorize]
[HttpGet]
public IActionResult Get()
{
return new JsonResult(from c in User.Claims select new { c.Type, c.Value });
}
Run Code Online (Sandbox Code Playgroud)
在我的startup.cs中,ConfigureServices()如下:
public IServiceProvider ConfigureServices(IServiceCollection services)
{
...
// configure identity server with stores, keys, clients and scopes
services.AddIdentityServer()
.AddCertificateFromStore(Configuration.GetSection("AuthorizationSettings"), loggerFactory.CreateLogger("Startup.ConfigureServices.AddCertificateFromStore"))
// this adds the config data from DB (clients, resources)
.AddConfigurationStore(options =>
{
options.DefaultSchema = "auth";
options.ConfigureDbContext = builder =>
{
builder.UseSqlServer(databaseSettings.MsSqlConnString,
sql => sql.MigrationsAssembly(migrationsAssembly));
};
})
// this adds the operational data from DB (codes, tokens, consents) …Run Code Online (Sandbox Code Playgroud)