auth0-java icon indicating copy to clipboard operation
auth0-java copied to clipboard

Get client (by ID) API should include Field Filter

Open bhatmadhavi opened this issue 3 years ago • 0 comments

Describe the problem you'd like to have solved

Current auth0-java SDK does not provide filter option to "get Client By Id" API, which is available in auth0-management API Please see attachment auth0-get-client-api This feature is useful if we intend to read only limited client fields.

Describe the ideal solution

Adding new method to ClientsEntity.java, which accepts "FieldsFilter" parameter. This way it won't impact existing get method

public Request<Client> get(String clientId, FieldsFilter filter) {
        Asserts.assertNotNull(clientId, "client id");

        HttpUrl.Builder builder = baseUrl
            .newBuilder()
            .addPathSegments("api/v2/clients")
            .addPathSegment(clientId);
        if (filter != null) {
            for (Map.Entry<String, Object> e : filter.getAsMap().entrySet()) {
                builder.addQueryParameter(e.getKey(), String.valueOf(e.getValue()));
            }
        }
        String url = builder.build().toString();
        CustomRequest<Client> request = new CustomRequest<>(client, url, "GET", new TypeReference<Client>() {
        });
        request.addHeader("Authorization", "Bearer " + apiToken);
        return request;
    }

Alternatives and current work-arounds

Additional information, if any

PR is created to address this https://github.com/auth0/auth0-java/pull/449

bhatmadhavi avatar Aug 10 '22 19:08 bhatmadhavi