/** * Get user name from Github, with the token provided. * @param token Github access token * @return The user found in Github * @throws IOException If fails */ private Identity fetch(final String token) throws IOException { final URI uri = UriBuilder .fromUri("https://api.github.com/user") .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() ); }