use of org.scribe.model.Response in project fitscales by paulburton.
the class RunKeeperSyncService method postOAuth.
@Override
protected void postOAuth() {
try {
OAuthRequest request = new OAuthRequest(Verb.GET, API_BASE + "/profile");
request.addHeader("Accept", "application/vnd.com.runkeeper.Profile+json");
oaService.signRequest(oaToken, request);
Response response = request.send();
String body = response.getBody();
if (DEBUG)
Log.d(TAG, "Got profile body " + body);
JSONObject json = new JSONObject(body);
user = json.getString("name");
} catch (Exception ex) {
user = "unknown";
}
}
use of org.scribe.model.Response in project sling by apache.
the class XingOauthAuthenticationHandler method fetchUser.
protected XingUser fetchUser(final Token accessToken) throws Exception {
final OAuthRequest request = new OAuthRequest(Verb.GET, usersMeUrl);
oAuthService.signRequest(accessToken, request);
final Response response = request.send();
final Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();
final Users users = gson.fromJson(response.getBody(), Users.class);
return users.getUsers().get(0);
}
Aggregations