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