Keycloak.loadUserProfile()上的Keycloak 403(禁止) [英] Keycloak 403 (Forbidden) on Keycloak.loadUserProfile()

查看:677
本文介绍了Keycloak.loadUserProfile()上的Keycloak 403(禁止)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Keycloak的新手.我尝试使用以下代码获取用户信息:

I am new to Keycloak. I have tried to get the user information using below code:

keycloakAuth.loadUserProfile().success(function(profile) {
  debugger
        console.log(profile);
    }).error(function(res) {
      debugger
        console.log('Failed to load profile');
    });

安装json是:

{
  "realm": "CheckRealm",
  "realm-public-key": "MIIBIjASDFJJK677132HJJAOCAQ8AMIIBCgKCAQEAgo4deAfr8BeqWOiCsddwMtH5nh8EK2cKIeInpt7LnoCyMsGj1HTP835HpslOURrR6Bgc42V7r6J/MIHqx3+KESTqpcQSe9ll6eUjzaMbIX2GPmy9OnviH6srUgOlDAKhL+/SDh/iv8RfErAPO9cxnoBWUUTyfyes1YRn34KILBdHZoaWk5mteJx9aV4bfA5tGTT6aF8o1NkCX1OUfXiaAD5sqKZV5vbI+QsOUsNshvGfE5JR2EpwZbWH/vRQVusxLURjC51v96ieQ8zUME5LwAQ0TgZcspHTb4Y+KuYRTuDQKuxRUYFeNbvqUGeT2s2sHMmWOQIDAQAB",
  "auth-server-url": "https://something.com/auth",
  "url": "https://something.com/auth",
  "ssl-required": "external",
  "resource": "sample-tracker",
  "clientId": "sample-tracker",
  "credentials": {
    "secret": "bnmbsdk87wq"
  }
}

我遇到了上述错误:无法加载资源:服务器的响应状态为403(禁止)

I got the mentioned error :Failed to load resource: the server responded with a status of 403 (Forbidden)

推荐答案

要解决这种情况,您需要配置密钥斗篷或RedHat单一登录(如果使用的是受支持的版本).

To solve this situation you need to configure your keycloak or RedHat Single Sign-On (if you are using the supported version).

  1. 打开密钥斗篷管理控制台,例如: http://localhost:8180/auth/admin .然后,点击配置> 客户端,然后选择帐户客户端. 必须启用帐户客户端.
  2. 接下来,仍然在配置"> 客户端中,选择您要访问的客户端,然后单击作用域"选项卡.添加帐户应用程序的查看配置文件角色.
  3. 用户还需要具有此权限.
  1. Open the keycloak admin console, for example: http://localhost:8180/auth/admin. Then click on Configure > clients and select the account client. The account client must be enabled.
  2. Next, still in Configure > clients, select the client that you are trying to access and click on the scope tab. Add the view-profile role of account application.
  3. The user also needs to have this permission.

https://issues.jboss.org/browse/中,有一个已解决的问题LIVEOAK-204 .

这篇关于Keycloak.loadUserProfile()上的Keycloak 403(禁止)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆