403 Forbidden error, while access the ClientRepresentation in keycloack
Asked Answered
T

1

1

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();
    }

Error which passed,

java.lang.Exception: ErrorStage:CLIENT_REPRESENTATION_ID,HTTP responseCode:403,StatusIno=Forbidden
Thersathersites answered 28/4, 2016 at 8:15 Comment(0)
N
5

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.

Norton answered 28/4, 2016 at 10:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.