Package org.scribe.model

Examples of org.scribe.model.OAuthRequest.send()


  public static void saveAccessToken(HttpServletRequest request, OAuthService service, Token accessToken) throws Exception {
   
        OAuthRequest _request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL);
        service.signRequest(accessToken, _request);
        Response _response = _request.send();
        if (_response.getCode() != 200)
          throw new OAuthException("Can query account information.");

        String contentType = _response.getHeader("Content-Type");
    if (contentType == null) contentType = "";
View Full Code Here


        final String userEndpoint = url + accessToken;
        OAuthRequest request = new OAuthRequest(Verb.GET, userEndpoint);
        request.addHeader("Accept", "application/vnd.com.runkeeper.User+json");
        final OAuthService service = runKeeperController.getOAuthService();
        service.signRequest(token, request);
        Response response = request.send();
        final int httpResponseCode = response.getCode();
        long then = System.currentTimeMillis();
        String body = response.getBody();

        if (httpResponseCode==200) {
View Full Code Here

            OAuthRequest request = new OAuthRequest(Verb.GET, activityURL);
            request.addQuerystringParameter("oauth_token", token.getToken());
            request.addHeader("Accept", "application/vnd.com.runkeeper.FitnessActivity+json");
            service.signRequest(token, request);
            long then = System.currentTimeMillis();
            Response response = request.send();
            final int httpResponseCode = response.getCode();
            String body = response.getBody();
            if (httpResponseCode ==200) {
                countSuccessfulApiCall(updateInfo.apiKey,
                                       updateInfo.objectTypes, then, activityURL);
View Full Code Here

            request.addHeader("If-Modified-Since", sinceFormatted);
            request.addQuerystringParameter("noEarlierThan", noEarlierFormatted);
        }
        service.signRequest(token, request);
        long then = System.currentTimeMillis();
        Response response = request.send();
        final int httpResponseCode = response.getCode();
        String body = response.getBody();
        if (httpResponseCode ==200) {
            JSONObject jsonObject = JSONObject.fromObject(body);
            final JSONArray items = jsonObject.getJSONArray("items");
View Full Code Here

            }
            OAuthService service = getOAuthService(updateInfo.apiKey);
            final String accessToken = guestService.getApiKeyAttribute(updateInfo.apiKey, "accessToken");
            final Token token = new Token(accessToken, guestService.getApiKeyAttribute(updateInfo.apiKey, "tokenSecret"));
            service.signRequest(token, request);
            Response response = request.send();
            httpResponseCode = response.getCode();
            if (httpResponseCode!=200)
                throw new UpdateFailedException("Unexpected response code: " + httpResponseCode);
            String json = response.getBody();
            JSONObject jsonObject = JSONObject.fromObject(json);
View Full Code Here

      request.setReadTimeout(30, TimeUnit.SECONDS);
      request.setCharset("UTF-8");
      Response response = null;

      try {
        response = request.send();
      } catch (OAuthConnectionException e) {
        throw e;
      }

      String responseBody = response.getBody();
View Full Code Here

    OAuthRequest request = new OAuthRequest(getAccessTokenVerb(), this.refreshTokenEndpoint);
    request.addQuerystringParameter(OAuthConstants.CLIENT_ID, apiKey);
    request.addQuerystringParameter(OAuthConstants.CLIENT_SECRET, apiSecret);
    request.addQuerystringParameter("grant_type", "refresh_token");
    request.addQuerystringParameter("refresh_token", refreshToken.getToken());
    Response response = request.send();
    return getAccessTokenExtractor().extract(response.getBody());
  }

  public String getBaseUrl() {
    return baseUrl;
View Full Code Here

            request.addHeader("Content-Type", mediaType);
        }

        oAuthService.signRequest(token, request);

        Response response = request.send();

        if (response.getCode() == 401 || response.getCode() == 403) {
            throw new InvalidCredentialsException("The OAuth Token is invalid, or has been revoked");
        } else if (response.getCode() != 200) {
            throw new IOException("Unexpected status code of " + response.getCode() + ": " + response.getBody() +
View Full Code Here

        + props.getKeystonePath() + accessToken;

    OAuthRequest oauthReq = new OAuthRequest(Verb.GET, url);
    oauthReq.addHeader(X_AUTH_HEADER, kmfAuthToken);

    return oauthReq.send();
  }

  private String obtainFilterToken() {
    Keystone keystone = new Keystone(props.getKeystoneHost() + ':'
        + props.getKeystonePort() + '/' + props.getOAuthVersion());
View Full Code Here

        //The ~ means yourself - so this should return the basic default information for your profile in XML format
        //https://developer.linkedin.com/documents/profile-api
        String url = "http://api.linkedin.com/v1/people/~";
        OAuthRequest request = new OAuthRequest(Verb.GET, url);
        service.signRequest(accessToken, request);
        Response response = request.send();
        System.out.println(response.getBody());
        System.out.println();System.out.println();

        System.out.println("********Get the profile in JSON********");
        //This basic call profile in JSON format
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.