/** * Get user name from Amazon, with the token provided. * @param token Amazon access token * @return The user found in Amazon * @throws java.io.IOException If fails */ private Identity fetch(final String token) throws IOException { final URI uri = UriBuilder .fromUri("https://api.amazon.com/user/profile") .queryParam("access_token", "{token}") .build(token); return this.parse( new JdkRequest(uri) .header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON) .fetch().as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_OK) .as(JsonResponse.class).json().readObject() ); }