Search in sources :

Example 6 with Response

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";
    }
}
Also used : OAuthRequest(org.scribe.model.OAuthRequest) Response(org.scribe.model.Response) JSONObject(org.json.JSONObject)

Example 7 with Response

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);
}
Also used : OAuthRequest(org.scribe.model.OAuthRequest) HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(org.scribe.model.Response) GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) Users(org.apache.sling.auth.xing.api.users.Users)

Aggregations

OAuthRequest (org.scribe.model.OAuthRequest)7 Response (org.scribe.model.Response)7 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 JSONObject (org.json.JSONObject)2 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 Users (org.apache.sling.auth.xing.api.users.Users)1 JsonParseException (org.codehaus.jackson.JsonParseException)1 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)1 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1 ServiceBuilder (org.scribe.builder.ServiceBuilder)1 OAuthService (org.scribe.oauth.OAuthService)1