Package org.scribe.model

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


     * @return
     */
    public String get(String url, String token, String secret) {
        OAuthRequest request = new OAuthRequest(Verb.GET, url);
        service.signRequest(new Token(token, secret), request); // the access token from step 4
        Response response = request.send();
        if (response.isSuccessful()) {
            return response.getBody();
        } else {
            return null;
        }
View Full Code Here


    }
   
    private String send(Verb verb, String params) throws Exception {
        OAuthRequest request = new OAuthRequest(verb, apiUrl + ((params != null) ? params : ""));
        request.addQuerystringParameter(OAuthConstants.ACCESS_TOKEN, apiAccessToken);
        Response response = request.send();
        if (response.isSuccessful()) {                   
            return response.getBody();
        } else {
            throw new Exception(String.format("Failed to poll %s. Got response code %s and body: %s", getApiUrl(), response.getCode(), response.getBody()));
        }
View Full Code Here

    //Adding grant_type parameter manually
    //Hard-coded the values for now until scribe comes up with an update
    request.addHeader("Content-Type", "application/x-www-form-urlencoded");
    request.addBodyParameter("grant_type", "authorization_code");  
    if(config.hasScope()) request.addQuerystringParameter(OAuthConstants.SCOPE, config.getScope());   
    Response response = request.send();
    return api.getAccessTokenExtractor().extract(response.getBody());
  }

  /**
   * {@inheritDoc}
 
View Full Code Here

      for (Map.Entry<String,String> param : params.entrySet()) {
        request.addQuerystringParameter(param.getKey(), param.getValue());
      }
    }
    service.signRequest(token, request);
    Response response = request.send();
    if (response.getCode() != 200) {
      ApiException exception = unmarshallResponse(response, ApiException.class);
      throw new XeroApiException(response.getCode() + " response: Error number "
          + exception.getErrorNumber() + ". " + exception.getMessage());       
    }
View Full Code Here

    // Now let's go and ask for a protected resource!
    OAuthRequest request = new OAuthRequest(Verb.GET,
        Constants.PROTECTED_RESOURCE_URL_GOOGLE);
    service.signRequest(accessToken, request);
    request.addHeader("GData-Version", "3.0");
    Response response = request.send();

    readDataProfile(response.getBody());
  }

  private void readDataProfile(String body) {
View Full Code Here

    // Now let's go and ask for a protected resource!
    OAuthRequest request = new OAuthRequest(Verb.GET,
        Constants.PROTECTED_RESOURCE_URL_FACEBOOK);
    service.signRequest(accessToken, request);
    Response response = request.send();
    readDataProfile(StringEscapeUtils.unescapeJava(response.getBody()));
  }

  private void readDataProfile(String body) {
    JSONParser jsonParser = new JSONParser();
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.