【问题标题】:Client not configured to receive access tokens via browser IdentityServer4客户端未配置为通过浏览器 IdentityServer4 接收访问令牌
【发布时间】:2020-11-05 11:57:41
【问题描述】:
let usrMgr = new UserManager({
  authority: "https://localhost:5001/",
  client_id: "clientname",
  redirect_uri: "https://localhost:3000/login/callback.html",
  response_type: "id_token token",
  scope: "openid"
});

usrMgr.signinRedirect();

我正在使用oidc-client-js 如上所示,通过我们的身份服务器进行身份验证。

在尝试进行身份验证时,我从身份服务器收到以下错误

我的身份服务器上的客户端是这样的

{
    "Enabled": true,
    "ClientId": "clientname",
    "ClientName": "Some Client Name",
    "AllowedGrantTypes": "implicit",
    "AllowedScopes": [ "openid", "profile", "email", "id:custom" ],
    "AllowOfflineAccess": true,
    "PostLogoutRedirectUris": [ "https://localhost:3000/signout-callback-oidc" ],
    "RedirectUris": [ "https://localhost:3000/login/callback.html" ],
    "FrontChannelLogoutUri": "https://localhost:3000/signout-oidc",
    "AllowAccessTokensViaBrowser": true
  }

我将 AllowAccessTokensViaBrowser 设置为 true,并将 AllowedGrantTypes 设置为隐式。

知道为什么我会收到“客户端未配置为通过浏览器接收访问令牌错误吗?

【问题讨论】:

    标签: javascript authentication identityserver4 openid


    【解决方案1】:

    如果您查看您看到的 IdentityServer 源代码

            //////////////////////////////////////////////////////////
            // check if response type contains an access token,
            // and if client is allowed to request access token via browser
            //////////////////////////////////////////////////////////
            var responseTypes = responseType.FromSpaceSeparatedString();
            if (responseTypes.Contains(OidcConstants.ResponseTypes.Token))
            {
                if (!request.Client.AllowAccessTokensViaBrowser)
                {
                    LogError("Client requested access token - but client is not configured to receive access tokens via browser", request);
                    return Invalid(request, description: "Client not configured to receive access tokens via browser");
                }
            }
    

    所以,我认为唯一的原因是如果您的配置文件中有一些拼写错误,或者有其他原因,AllowAccessTokensViaBrowser 未设置为 true。源代码可以在here找到。也许是一些大写/小写问题?

    【讨论】:

      猜你喜欢
      • 2018-10-27
      • 2020-12-07
      • 2017-05-01
      • 2017-12-07
      • 2017-10-27
      • 2018-09-26
      • 2022-01-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多