Fetching Email Address is slow

Hi everyone,

I have implemented a small Java sample to get the User-data (especially email) by requesting the API:

private JSONObject getJsonUserData(String userId) throws UnirestException, ParseException, AuthException {
    if (this.accessToken == null) {
        HttpResponse<String> r1 = Unirest.post(issuerUri + "oauth/token")
                .header("content-type", "application/json")
                .body("{\"client_id\":\"" + clientId +
                        "\",\"client_secret\":\"" + clientSecret +
                        "\",\"audience\":\"" + issuerUri +
                        "api/v2/\",\"grant_type\":\"client_credentials\"}")
                .asString();

        JSONObject o = (JSONObject) (new JSONParser()).parse(r1.getBody());
        this.accessToken = o.get("access_token").toString();
    }

    HttpResponse<String> response = Unirest.get(issuerUri + "api/v2/users/" + URLEncoder.encode(userId))
            .header("authorization", "Bearer " + this.accessToken)
            .asString();

    return (JSONObject) (new JSONParser()).parse(response.getBody());
}

Fetching the “AccessToken” is quite fast, but the second request to the “/api/v2/users/XXX” is loading endless.

Any ideas?

Best,
Peter

Hi @StuzfuzDwineR,

This is hard to diagnose without more info. How slow is it? Or is it endless (not responding)? If you are seeing an error that would be helpful too.

hi @dan.woda
thanks for your reply.
It is loading endless.

Is there a better way available to fetch Email addresses from Users?

It shouldn’t be loading endless. Please post your code.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.