Package oauth.signpost

Examples of oauth.signpost.OAuthConsumer


    URL url = new URL("https://palacehotelsoftware.freshbooks.com/api/2.1/xml-in");

    HttpURLConnection request = (HttpURLConnection) url
        .openConnection();

    OAuthConsumer consumer = new DefaultOAuthConsumer(
        env.get("freshbooksConsumerKey"),
        env.get("freshbooksConsumerSecret"));
    consumer.setMessageSigner(new PlainTextMessageSigner());
    consumer.setTokenWithSecret(guestService.getApiKeyAttribute(updateInfo.apiKey,"accessToken"),
                                    guestService.getApiKeyAttribute(updateInfo.apiKey,"tokenSecret"));

    consumer.sign(request);
   
    request.setDoOutput(true);
    Writer requestWriter = new OutputStreamWriter(
        request.getOutputStream());
View Full Code Here


    OAuthConsumer setupConsumer(ApiKey apiKey) {
        String api_key = guestService.getApiKeyAttribute(apiKey, "bodymediaConsumerKey");
        String bodymediaConsumerSecret = guestService.getApiKeyAttribute(apiKey, "bodymediaConsumerSecret");

        OAuthConsumer consumer = new CommonsHttpOAuthConsumer(api_key, bodymediaConsumerSecret);

        String accessToken = guestService.getApiKeyAttribute(apiKey, "accessToken");
        String tokenSecret = guestService.getApiKeyAttribute(apiKey, "tokenSecret");

        consumer.setTokenWithSecret(accessToken, tokenSecret);
        return consumer;
    }
View Full Code Here

        // The first time we do this there won't be an apiKeyAttribute yet.  In that case get the
        // registration date for the user and store that.

        if(updateStartDate == null) {
            OAuthConsumer consumer = setupConsumer(updateInfo.apiKey);
            String api_key = guestService.getApiKeyAttribute(updateInfo.apiKey, "bodymediaConsumerKey");
            updateStartDate = getUserRegistrationDate(updateInfo, api_key, consumer);

            // Store in the apiKeyAttribute for next time
            guestService.setApiKeyAttribute(updateInfo.apiKey, updateKeyName, updateStartDate);
View Full Code Here

            throw new Exception("Error: " + statusCode + " Unexpected error trying to get BodyMedia user registration date for guestId="+updateInfo.getGuestId());
        }
    }

    public TimezoneMap getTimezoneMap(UpdateInfo updateInfo) throws Exception {
            OAuthConsumer consumer = setupConsumer(updateInfo.apiKey);
            String api_key = guestService.getApiKeyAttribute(updateInfo.apiKey, "bodymediaConsumerKey");
            JSONArray timezoneMapJson = getUserTimezoneHistory(updateInfo, api_key, consumer);
            TimezoneMap ret= new TimezoneMap();

            try{
View Full Code Here

      oauthCallback += "?guestId=" + request.getParameter("guestId");

        String consumerKey = getConsumerKey();
    String consumerSecret = getConsumerSecret();
   
    OAuthConsumer consumer = new DefaultOAuthConsumer(
                consumerKey,
                consumerSecret);
       
        OAuthProvider provider = new DefaultOAuthProvider(
            "https://api.linkedin.com/uas/oauth/requestToken",
            "https://api.linkedin.com/uas/oauth/accessToken",
            "https://api.linkedin.com/uas/oauth/authorize");
       
    request.getSession().setAttribute(LINKEDIN_OAUTH_CONSUMER, consumer);
    request.getSession().setAttribute(LINKEDIN_OAUTH_PROVIDER, provider);
    System.out.println("the token secret is: " + consumer.getTokenSecret());
   
    String approvalPageUrl = provider.retrieveRequestToken(consumer, oauthCallback);
   
    return "redirect:" + approvalPageUrl;
  }
View Full Code Here

    return "redirect:" + approvalPageUrl;
  }
 
  @RequestMapping(value="/upgradeToken")
  public String upgradeToken(HttpServletRequest request) throws OAuthMessageSignerException, OAuthNotAuthorizedException, OAuthExpectationFailedException, OAuthCommunicationException {
    OAuthConsumer consumer = (OAuthConsumer) request.getSession().getAttribute(LINKEDIN_OAUTH_CONSUMER);
    OAuthProvider provider = (OAuthProvider) request.getSession().getAttribute(LINKEDIN_OAUTH_PROVIDER);
    String verifier = request.getParameter("oauth_verifier");
    provider.retrieveAccessToken(consumer, verifier);
    Guest guest = AuthHelper.getGuest();

        final Connector connector = Connector.getConnector("linkedin");
        final ApiKey apiKey = guestService.createApiKey(guest.getId(), connector);

    guestService.setApiKeyAttribute(apiKey, "accessToken", consumer.getToken());
    guestService.setApiKeyAttribute(apiKey, "tokenSecret", consumer.getTokenSecret());

    return "redirect:/app/from/"+connector.getName();
  }
View Full Code Here

    String oauthCallback = env.get("homeBaseUrl")
    + "dropbox/upgradeToken";
    if (request.getParameter("guestId")!=null)
      oauthCallback += "?guestId=" + request.getParameter("guestId");

        OAuthConsumer consumer = new DefaultOAuthConsumer(
                getConsumerKey(),
                getConsumerSecret());
       
        OAuthProvider provider = new DefaultOAuthProvider(
            "http://api.getdropbox.com/0/oauth/request_token",
            "http://api.getdropbox.com/0/oauth/access_token",
            "http://api.getdropbox.com/0/oauth/authorize");
       
    request.getSession().setAttribute(DROPBOX_OAUTH_CONSUMER, consumer);
    request.getSession().setAttribute(DROPBOX_OAUTH_PROVIDER, provider);
    System.out.println("the token secret is: " + consumer.getTokenSecret());
   
    String approvalPageUrl = provider.retrieveRequestToken(consumer, oauthCallback);
   
    return "redirect:" + approvalPageUrl;
  }
View Full Code Here

  }

  @RequestMapping(value = "/upgradeToken")
  public String upgradeToken(HttpServletRequest request,
      HttpServletResponse response) throws OAuthException, OAuthMessageSignerException, OAuthNotAuthorizedException, OAuthExpectationFailedException, OAuthCommunicationException {
    OAuthConsumer consumer = (OAuthConsumer) request.getSession().getAttribute(DROPBOX_OAUTH_CONSUMER);
    OAuthProvider provider = (OAuthProvider) request.getSession().getAttribute(DROPBOX_OAUTH_PROVIDER);
    String verifier = request.getParameter("oauth_verifier");
    provider.retrieveAccessToken(consumer, verifier);
    Guest guest = AuthHelper.getGuest();
        final Connector connector = Connector.getConnector("dropbox");
        final ApiKey apiKey = guestService.createApiKey(guest.getId(), connector);

    guestService.setApiKeyAttribute(apiKey, "accessToken", consumer.getToken());
    guestService.setApiKeyAttribute(apiKey, "tokenSecret", consumer.getTokenSecret());
   
    return "redirect:/app/from/"+connector.getName() ;
  }
View Full Code Here

    OAuthConsumer setupConsumer(ApiKey apiKey) {
    String twitterConsumerKey = guestService.getApiKeyAttribute(apiKey, "twitterConsumerKey");
    String twitterConsumerSecret = guestService.getApiKeyAttribute(apiKey, "twitterConsumerSecret");

        OAuthConsumer consumer = new CommonsHttpOAuthConsumer(
        twitterConsumerKey,
        twitterConsumerSecret);

    String accessToken = guestService.getApiKeyAttribute(apiKey, "accessToken");
    String tokenSecret = guestService.getApiKeyAttribute(apiKey,"tokenSecret");
   
    consumer.setTokenWithSecret(accessToken,
        tokenSecret);

        return consumer;
  }
View Full Code Here

    }

    @Override
  public void updateConnectorDataHistory(UpdateInfo updateInfo) throws Exception {
        initChannelMapping(updateInfo);
        final OAuthConsumer consumer = setupConsumer(updateInfo.apiKey);

    List<ObjectType> objectTypes = updateInfo.objectTypes();
    if (objectTypes.contains(ObjectType.getObjectType(connector(), "tweet"))) {
      getStatuses(updateInfo, consumer);
    } else if (objectTypes.contains(ObjectType.getObjectType(connector(), "mention"))) {
View Full Code Here

TOP

Related Classes of oauth.signpost.OAuthConsumer

Copyright © 2018 www.massapicom. 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.