Package oauth.signpost.commonshttp

Examples of oauth.signpost.commonshttp.CommonsHttpOAuthProvider


        return new CommonsHttpOAuthConsumer(consumerKey, consumerSecret);
    }
   
    public synchronized OAuthProvider getProvider() {
        if (oauthProvider == null) {
            oauthProvider = new CommonsHttpOAuthProvider(
                    getRequestTokenServiceURL(), getAccessTokenServiceURL(), getUserAuthorizationURL());
        }
        return oauthProvider;
    }
View Full Code Here


    System.setProperty("debug", "true");
   
    OAuthConsumer consumer = new CommonsHttpOAuthConsumer(consumerKey, consumerSecret);

    // Note: we have to add the consumer key in the authorization URL to make it work
    OAuthProvider provider = new CommonsHttpOAuthProvider(REQUEST_TOKEN_URL,
                               ACCESS_TOKEN_URL,
                              AUTHORIZATION_URL + "&client_id=" + consumerKey);
    /*
     *  This has to be done once to get request token
     */
    provider.setOAuth10a(true);
    // for some reason, SignPost does not append oauth_callback so I
    // added it directly into the AUTHORIZATION_URL
    String requestUrl = provider.retrieveRequestToken(consumer, CALLBACK_URL);
    System.out.println("Copy/Paste the following URL in your browser: " + requestUrl);
    System.out.print("Enter your token: ");
    // read authorization code
    Scanner scanner = new Scanner(System.in);
    String authorizationCode = scanner.nextLine().trim();

    provider.retrieveAccessToken(consumer, authorizationCode);
       
    String accessToken = consumer.getToken();
    String tokenSecret = consumer.getTokenSecret();
    System.out.println("Token: " + accessToken + ". Secret: " + tokenSecret);

View Full Code Here

    additionalParameter.put("api_key", apiKey);
    consumer.setAdditionalParameters(additionalParameter);

    HttpClient httpClient = env.getHttpClient();

    OAuthProvider provider = new CommonsHttpOAuthProvider(
        "https://api.bodymedia.com/oauth/request_token?api_key="+apiKey,
        "https://api.bodymedia.com/oauth/access_token?api_key="+apiKey,
        "https://api.bodymedia.com/oauth/authorize?api_key="+apiKey, httpClient);

    request.getSession().setAttribute(BODYMEDIA_OAUTH_CONSUMER, consumer);
    request.getSession().setAttribute(BODYMEDIA_OAUTH_PROVIDER, provider);

        String approvalPageUrl = null;
        try {
            approvalPageUrl = provider.retrieveRequestToken(consumer,
                    oauthCallback);
        } catch (Throwable t) {
            logger.error("Couldn't retrieve BodyMedia request token.");
            t.printStackTrace();
            notificationsService.addNamedNotification(AuthHelper.getGuestId(),
View Full Code Here

                                accessToken);
        consumer.setAdditionalParameters(additionalParameter);

        HttpClient httpClient = env.getHttpClient();

        OAuthProvider provider = new CommonsHttpOAuthProvider(
                "https://api.bodymedia.com/oauth/request_token?api_key="+bodymediaConsumerKey,
                "https://api.bodymedia.com/oauth/access_token?api_key="+bodymediaConsumerKey,
                "https://api.bodymedia.com/oauth/authorize?api_key="+bodymediaConsumerKey, httpClient);

        try {
            provider.retrieveAccessToken(consumer, null);

            guestService.setApiKeyAttribute(updateInfo.apiKey,
                                            "accessToken", consumer.getToken());
            guestService.setApiKeyAttribute(updateInfo.apiKey,
                                            "tokenSecret", consumer.getTokenSecret());
            guestService.setApiKeyAttribute(updateInfo.apiKey,
                                            "tokenExpiration", provider.getResponseParameters().get("xoauth_token_expiration_time").first());

            // Record this connector as having status up
            guestService.setApiKeyStatus(updateInfo.apiKey.getId(), ApiKey.Status.STATUS_UP, null, null);
            // Schedule an update for this connector
            connectorUpdateService.updateConnector(updateInfo.apiKey, false);
View Full Code Here

   
    OAuthConsumer consumer = new CommonsHttpOAuthConsumer(
                consumerKey,
                consumerSecret);
       
        OAuthProvider provider = new CommonsHttpOAuthProvider(
            "http://www.khanacademy.org/api/auth/request_token",
            "http://www.khanacademy.org/api/auth/access_token",
            "http://www.khanacademy.org/api/auth/authorize");
       
    request.getSession().setAttribute(KHAN_OAUTH_CONSUMER, consumer);
    request.getSession().setAttribute(KHAN_OAUTH_PROVIDER, provider);

    try {
      provider.retrieveRequestToken(consumer, oauthCallback);
    } catch (Throwable e) {
      //TODO: a redirection happens here, and it should be handled
      System.out.println("redirection here");
    }
    System.out.println("the token secret is (musn't be null): " + consumer.getTokenSecret());
View Full Code Here

                getConsumerKey(),
                getConsumerSecret());
       
        HttpClient httpClient = env.getHttpClient();
       
        OAuthProvider provider = new CommonsHttpOAuthProvider(
            "https://api.twitter.com/oauth/request_token",
            "https://api.twitter.com/oauth/access_token",
            "https://api.twitter.com/oauth/authorize",
            httpClient);
       
    request.getSession().setAttribute(TWITTER_OAUTH_CONSUMER, consumer);
    request.getSession().setAttribute(TWITTER_OAUTH_PROVIDER, provider);
    System.out.println("the token secret is: " + consumer.getTokenSecret());
        if (request.getParameter("apiKeyId") != null)
            oauthCallback += "?apiKeyId=" + request.getParameter("apiKeyId");

    String approvalPageUrl = provider.retrieveRequestToken(consumer, oauthCallback);
   
    return "redirect:" + approvalPageUrl;
  }
View Full Code Here

    public static void main(String[] args) throws Exception {

        OAuthConsumer consumer = new CommonsHttpOAuthConsumer("2qnk0OzpuzzU",
                "Ctp1QtFbtSaFhOJbOLMCUPio9c75zIaG");

        OAuthProvider provider = new CommonsHttpOAuthProvider(
                "https://fireeagle.yahooapis.com/oauth/request_token",
                "https://fireeagle.yahooapis.com/oauth/access_token",
                "https://fireeagle.yahoo.net/oauth/authorize");

        System.out.println("Fetching request token from Fire Eagle...");

        // we do not support callbacks, thus pass OOB
        String authUrl = provider.retrieveRequestToken(consumer, "http://www.example.com");

        System.out.println("Request token: " + consumer.getToken());
        System.out.println("Token secret: " + consumer.getTokenSecret());

        System.out.println("Now visit:\n" + authUrl + "\n... and grant this app authorization");
        System.out.println("Enter the verification code and hit ENTER when you're done");

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String code = br.readLine();

        System.out.println("Fetching access token from Fire Eagle...");

        provider.retrieveAccessToken(consumer, code);

        System.out.println("Access token: " + consumer.getToken());
        System.out.println("Token secret: " + consumer.getTokenSecret());

        HttpPost request = new HttpPost("https://fireeagle.yahooapis.com/api/0.1/update");
View Full Code Here

        this(info, true);
    }

    public OAuth(ServiceInfo info, boolean use10a) {
        this.info = info;
        this.provider = new CommonsHttpOAuthProvider(info.requestTokenURL, info.accessTokenURL, info.authorizationURL);
        this.provider.setOAuth10a(use10a);
    }
View Full Code Here

TOP

Related Classes of oauth.signpost.commonshttp.CommonsHttpOAuthProvider

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.