首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Identityserver 4和Ocelot

Identityserver 4和Ocelot
EN

Stack Overflow用户
提问于 2019-01-07 00:17:59
回答 1查看 3K关注 0票数 5

我试图在IS4和https://ocelot.readthedocs.io/en/latest/features/authentication.html之后使用Ocelot

在使用时

代码语言:javascript
复制
public void ConfigureServices(IServiceCollection services)
{
    var authenticationProviderKey = "TestKey";

    services.AddAuthentication()
        .AddJwtBearer(authenticationProviderKey, x =>
        {
        });
}

如果在TestKey中使用“ocelot.json”,则在启动应用程序时会引发一个错误。

无法启动Ocelot,错误有: TestKey,AllowedScopes:[]是不支持的身份验证提供程序

你知道怎么回事吗?我需要在我的IdentityServer应用程序中设置一些特别的东西吗?

EN

回答 1

Stack Overflow用户

发布于 2020-02-14 15:57:45

您需要添加以下选项,例如:

代码语言:javascript
复制
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
    .AddJwtBearer(options =>
    {
        // base-address of your identityserver
        options.Authority = "https://demo.identityserver.io";

        // name of the API resource
        options.Audience = "api1";
    });

更多信息请访问:http://docs.identityserver.io/en/latest/topics/apis.html#

您还需要将API资源添加到标识服务器中:

代码语言:javascript
复制
new ApiResource("api1", "Some API 1")

请参见:

http://docs.identityserver.io/en/latest/topics/resources.htmlresource.html#refapiresource

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54067154

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档