403禁止错误,在访问密钥克隆中的ClientRepresentation时 [英] 403 Forbidden error, while access the ClientRepresentation in keycloack

查看:156
本文介绍了403禁止错误,在访问密钥克隆中的ClientRepresentation时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在应用程序中使用keycloak API.当我们尝试检索领域的客户"列表时,它传递了403禁止错误.高度赞赏您为避免这种情况发表的评论.

We use keycloak API in our application. When we try to retrieve the Client list of the realm it pass 403 forbidden error. Highly appreciate your comments for avoid this matter.

    String authServer = UriUtils.getOrigin(httpRequest.getRequestURL().toString()) + AUTH_CONTEXT_PATH;
    String token = httpRequest.getHeader("Authorization").replaceAll("Bearer ", "");
    String realmClientsUrl = authServer+"/admin/realms/testrealm/clients/"+getClientRepresentationId(authServer,realm,token);
    ClientRequest request = getClientRequest(realmClientsUrl,token);
    ClientResponse<String> response;
    ClientRepresentation clientRepresentation = null;
    try{
        response = request.get(String.class);
        validateResponse(response,"CLIENT_REPRESENTATION");
        clientRepresentation = response.getEntity(ClientRepresentation.class);
        return clientRepresentation;
    } catch (Exception e) {

        e.printStackTrace();
    }

通过的错误

java.lang.Exception: ErrorStage:CLIENT_REPRESENTATION_ID,HTTP responseCode:403,StatusIno=Forbidden

推荐答案

如果登录的用户没有相关的客户端角色"访问权限,则可能会收到此错误.在领域管理下,将客户端角色访问权限添加为查看客户端".

You might get this error if the logged in user doesn't have the relevant Client Roles access. Add the client role access as "View Client" under realm-management.

这篇关于403禁止错误,在访问密钥克隆中的ClientRepresentation时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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