Examples of OAuthClient


Examples of net.oauth.client.OAuthClient

  public void fetchAccessToken()
  {
   
    // System.out.println("fetchAccessToken: requestToken=" + this.getRequestToken());
   
    OAuthClient client = getOAuthClient();
   
    OAuthMessage responseMsg = null;
   
    OAuthAccessor access = this.createOAuthAccessor();
   
    try
    {
     
        //
        //  request the Access token
        //
       
        access.accessToken = requestToken.getPublicKey();
        access.requestToken = requestToken.getPublicKey();
        access.tokenSecret = requestToken.getSecret();
       
        responseMsg = client.invoke(access, "GET", this.getClientSettings().getOAuthAccessTokenUrl(), null);
       
        this.getUserSpecificAccessToken().setPublicKey(responseMsg.getParameter("oauth_token"));
        this.getUserSpecificAccessToken().setSecret(responseMsg.getParameter("oauth_token_secret"));
     
    } catch (Exception e) {
View Full Code Here

Examples of net.oauth.client.OAuthClient

  public String getUserAuthorizationUrl()
  {
   
    String url = null;

    OAuthClient client = getOAuthClient();
   
    OAuthAccessor access = this.createOAuthAccessor();
   
    try
    {
      this.requestToken = null;
      access.requestToken = null;
      access.accessToken = null;
      access.tokenSecret = null;
     
      //
      //  send GET request to the Request Token URL
      //
     
      client.getRequestToken(access);
     
      // store the Request Token values
      requestToken = new Token();
      requestToken.setPublicKey(access.requestToken);
      requestToken.setSecret(access.tokenSecret);
View Full Code Here

Examples of net.oauth.client.OAuthClient

 
  protected String sendHttpRequest(String baseUrl, String method, java.util.Map<String, String> params, Token token)
  {
   
    OAuthClient client = getOAuthClient();
   
    OAuthMessage responseMsg = null;
   
   
    OAuthAccessor access = this.createOAuthAccessor();
   
    access.accessToken = token.getPublicKey();
    access.tokenSecret = token.getSecret();
   
    if (params == null)
    {
      params = new HashMap<String, String>();
    }
   
   
    try
    {
                 
      responseMsg = client.invoke(access, method, baseUrl, params.entrySet());
     
      return responseMsg.readBodyAsString();
     
    }
    catch (Exception e)
View Full Code Here

Examples of net.oauth.client.OAuthClient

   * request token).
   */
  public final void testCheckAuthorizationNoRequestToken() {
    // Setup.
    LoginFormHandler loginForm = mock(LoginFormHandler.class);
    OAuthClient client = mock(OAuthClient.class);
    PersistenceManager pm = mock(PersistenceManager.class);
    PersistenceManagerFactory pmf = mock(PersistenceManagerFactory.class);

    OAuthAccessor accessor = buildAccessor(CONSUMER_KEY, CONSUMER_SECRET,
        REQUEST_TOKEN_URL, AUTHORIZE_URL, CALLBACK_URL, ACCESS_TOKEN_URL);
View Full Code Here

Examples of net.oauth.client.OAuthClient

        OAuthAccessor accessor = consumerDataObj.getAccessor();
        OAuthMessage message = accessor.newRequestMessage("POST", rpcServerUrl, null, bodyStream);
        message.getHeaders().add(
            new SimpleEntry<String, String>(HttpMessage.CONTENT_TYPE, "application/json"));
        message.getHeaders().add(new SimpleEntry<String, String>("oauth_version", "1.0"));
        OAuthClient client = new OAuthClient(httpFetcher);
        responseStream = client.invoke(message, net.oauth.ParameterStyle.BODY).getBodyAsStream();
      }

      String responseString = HttpFetcher.readInputStream(responseStream);
      LOG.info("Response returned: " + responseString);
View Full Code Here

Examples of net.oauth.client.OAuthClient

        OAuthAccessor accessor = new OAuthAccessor(consumer);

        OAuthMessage msg = accessor
            .newRequestMessage(method, url, params.entrySet());

        OAuthClient client = new OAuthClient(new URLConnectionClient());

        return client.access(msg, style);
    }
View Full Code Here

Examples of net.oauth.client.OAuthClient

        OAuthServiceProvider provider;
        OAuthConsumer consumer;
        OAuthAccessor accessor;

        OAuthClient client = new OAuthClient(new URLConnectionClient());

        oAuthParams.setErrorMessage(null);
        String temporaryCredentialsEndpointUrl = oAuthParams.getTemporaryCredentialsEndpoint();
        if (temporaryCredentialsEndpointUrl == null || "".equals(temporaryCredentialsEndpointUrl)) {
            oAuthParams.setErrorMessage("Missing temporary credentials endpoint url");
        }
        String clientId = oAuthParams.getClientID();
        if (clientId == null || "".equals(clientId)) {
            oAuthParams.setErrorMessage("Missing client identifier");
        }
        String secret = oAuthParams.getClientSecret();
        if (secret == null || "".equals(secret)) {
            oAuthParams.setErrorMessage("Missing client shared-secret");
        }

        if (oAuthParams.getErrorMessage() == null) {
            provider = new OAuthServiceProvider(temporaryCredentialsEndpointUrl,
                oAuthParams.getResourceOwnerAuthorizationEndpoint(), oAuthParams.getTokenRequestEndpoint());
            consumer = new OAuthConsumer(null, clientId,
                secret,
                provider);
            accessor = new OAuthAccessor(consumer);

            Map<String, String> parameters = new HashMap<String, String>();
            parameters.put(OAuth.OAUTH_SIGNATURE_METHOD, oAuthParams.getSignatureMethod());
            parameters.put(OAuth.OAUTH_NONCE, UUID.randomUUID().toString());
            parameters.put(OAuth.OAUTH_TIMESTAMP, String.valueOf(System.currentTimeMillis() / 1000));
            parameters.put(OAuth.OAUTH_CALLBACK, oAuthParams.getCallbackURL());
            parameters.put("realm", "private");
            parameters.put("x_oauth_scope", "read_info,modify_info");
            parameters.put("x_oauth_uri", "/resources/person/*");


            try {
                accessor.consumer
                    .setProperty(OAuthClient.PARAMETER_STYLE, ParameterStyle.AUTHORIZATION_HEADER);
                client.getRequestToken(accessor, OAuthMessage.POST, parameters.entrySet());
            } catch (Exception e) {
                oAuthParams.setErrorMessage(e.toString());
            }

            oAuthParams.setOauthToken(accessor.requestToken);
View Full Code Here

Examples of net.oauth.client.OAuthClient

  private OAuthClient getOAuthClient() {
    if (httpClient == null) {
      httpClient = new HttpClientImpl();
    }

    return new OAuthClient(httpClient);
  }
View Full Code Here

Examples of net.oauth.client.OAuthClient

    }

    public ArrayOfInvoice getInvoices() throws XeroClientException, XeroClientUnexpectedException {
        ArrayOfInvoice arrayOfInvoices = null;
        try {
            OAuthClient client = new OAuthClient(new HttpClient3());
            OAuthAccessor accessor = buildAccessor();
            OAuthMessage response = client.invoke(accessor, OAuthMessage.GET, endpointUrl + "Invoices", null);
            arrayOfInvoices = XeroXmlManager.xmlToInvoices(response.getBodyAsStream());
        } catch (OAuthProblemException ex) {
            throw new XeroClientException("Error getting invoices", ex);
        } catch (Exception ex) {
            throw new XeroClientUnexpectedException("", ex);
View Full Code Here

Examples of net.oauth.client.OAuthClient

    }

    public Report getReport(String reportUrl) throws XeroClientException, XeroClientUnexpectedException {
        Report report = null;
        try {
            OAuthClient client = new OAuthClient(new HttpClient3());
            OAuthAccessor accessor = buildAccessor();
            OAuthMessage response = client.invoke(accessor, OAuthMessage.GET, endpointUrl + "Reports" + reportUrl, null);
            ResponseType responseType = XeroXmlManager.xmlToResponse(response.getBodyAsStream());
            if (responseType != null && responseType.getReports() != null
                    && responseType.getReports().getReport() != null && responseType.getReports().getReport().size() > 0) {
                report = responseType.getReports().getReport().get(0);
            }
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.