Identity Server 3-客户端应用程序未知或未经授权

乔恩

我收到错误消息“客户端应用程序未知或未被授权。” 访问我网站的保护区时。

这是我的客户:

public static class Clients
{
    public static IEnumerable<Client> Get()
    {
        return new[]
        {
            new Client
            {
                Enabled = true,
                ClientName = "Web Application",
                ClientId = "webapplication",
                Flow = Flows.AuthorizationCode,

                ClientSecrets = new List<Secret>
                {
                    new Secret("webappsecret".Sha256())
                },

                RedirectUris = new List<string>
                {
                    UrlManager.WebApplication
                },
                PostLogoutRedirectUris = new List<string>
                {
                    UrlManager.WebApplication
                },

                AllowedScopes = new List<string>
                {
                    Constants.StandardScopes.OpenId,
                    Constants.StandardScopes.Profile,
                    Constants.StandardScopes.Email,
                    Constants.StandardScopes.Roles,
                    Constants.StandardScopes.OfflineAccess,
                    "read",
                    "write"
                }
            }
        };
    }
}

这是我的Web应用程序启动:

public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = "Cookies"
        });

        app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
        {
            Authority = UrlManager.AuthenticationService + "identity",

            ClientId = "webapplication",
            Scope = "openid profile",
            ResponseType = "code id_token",
            RedirectUri = UrlManager.WebApplication,

            SignInAsAuthenticationType = "Cookies"
        });
    }
}

这是我的身份验证服务(已安装IDS3的地方)启动:

public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.Map("/identity", idsrvApp =>
        {
            idsrvApp.UseIdentityServer(new IdentityServerOptions
            {
                SiteName = "Authentication Service - Embedded IdentityServer",
                SigningCertificate = Certificate.LoadCertificate(),

                Factory = new IdentityServerServiceFactory()
                            .UseInMemoryUsers(Users.Get())
                            .UseInMemoryClients(Clients.Get())
                            .UseInMemoryScopes(Scopes.Get())
            });
        });
    }
}

这是UrlManager:

public static class UrlManager
{
    public static string WebApplication
    {
        get { return "https://localhost:44381/"; }
    }

    public static string AuthenticationService
    {
        get { return "https://localhost:44329/"; }
    }
}

这是我的家庭控制器:

public class HomeController : Controller
{
    public ActionResult Index()
    {
        return View();
    }

    [Authorize]
    public ActionResult Private()
    {
        return View((User as ClaimsPrincipal).Claims);
    }
}

当我访问专用时,我得到一个Identity Server 3屏幕,该屏幕显示错误消息“客户端应用程序未知或未被授权。”。

我已经读到这可能来自重定向URI中的不匹配,但据我所知是正确的。我不知道还有什么原因。如果我将流程更改为隐式,但我想实现AuthorizationCode流程,则该应用程序将正常运行。

该文档似乎也没有对此有所说明。

卡尔提克

为客户端配置了授权码流程

流= Flows.AuthorizationCode

但是启动中的响应类型设置为混合流。

ResponseType =“代码id_token”

尝试将其更改为

ResponseType =“ code”(或将Flow类型更改为Hybrid)

以下是ResponseType和相应流程的列表在此处输入图片说明

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Thinktecture Identity Server 3:用于保护WEB API免受未授权访问的客户端机密

在应用程序设置中定义Identity Server客户端的未公开方法

将外部登录令牌从Identity Server流到客户端应用程序

将Core MVC Client与IdentityServer v3一起使用-客户端应用程序未知或未经授权

MS Identity Azure应用程序已注册,但以隐式流发送未经授权的客户端

托管在iss中后,客户端应用程序未重定向到Identity Server 4

Identity Server 3身份验证/授权

未知客户端或未启用客户端的Identity Server 4

我的客户端应用程序从 QT Fortune Server 示例中读取未知字符

Identity Server 4:为什么我会收到非授权客户端?

Identity Server 3,从所有选项卡中注销 Js 应用程序

Identity Server4未经授权的错误

覆盖默认的Identity Server 4客户端

从 Identity Server 4 注销不会从客户端注销

错误应用程序Java客户端-server

获取 401 - 调用受 Identity Server 3 保护的 .Net Core 2.2 API 时出现未经授权的错误

谁为 Identity Server 4 提供客户端 ID 和客户端密码?

Identity Server 4的API授权不断返回401未经授权

Identity Server 4,未经授权的API可以调用自省端点

Thinktecture Identity Server 3 Asp.Net身份示例,不断获得401授权被拒绝

处理Identity Server客户端凭据流时自签名客户端证书中的问题

具有Identity和EF的3层应用程序

Identity Server 4授权代码流示例

Identity Server:通过MVC客户端中的混合流向ClaimPrincipal添加声明

Identity4Server是许多SPA客户端的最佳方法吗?

您如何正确授予 Identity Server 4.0.3 中给定客户端对 ApiResource 的访问权限?

在IdentityServerAuthenticationOptions上更改ApiName之后,客户端仍可与Identity Server 4一起使用

Identity Server 4-检查iframe会话问题-OIDC客户端

带有客户端机密的Identity Server 4混合流错误