throw new IOException(String.format("Error getting access token: [%s: %s]",
webResponse.getStatusCode(), webResponse.getStatusMessage()));
}
final long currentTime = System.currentTimeMillis();
final ObjectMapper mapper = new ObjectMapper();
final Map map = mapper.readValue(webResponse.getContentAsStream(), Map.class);
final String accessToken = map.get("access_token").toString();
final Integer expiresIn = Integer.valueOf(map.get("expires_in").toString());
return new OAuthToken(refreshToken, accessToken,
currentTime + TimeUnit.MILLISECONDS.convert(expiresIn, TimeUnit.SECONDS));
}