1

我们在应用程序中使用 keycloak API。当我们尝试检索领域的客户端列表时,它会传递 403 禁止错误。非常感谢您的评论以避免此问题。

    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
4

1 回答 1

4

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

于 2016-04-28T10:41:07.600 回答