Examples of OAuthAuthorization


Examples of facebook4j.auth.OAuthAuthorization

            parameters[0] = new HttpParameter("hoge", "1");
            ConfigurationBuilder cb = new ConfigurationBuilder()
                                        .setAppSecretProofEnabled(true)
                                        .setOAuthAppSecret("1234567890123456")
                                        .setOAuthAccessToken("access_token");
            OAuthAuthorization authorization = new OAuthAuthorization(cb.build());
            Map<String, String> requestHeaders = new HashMap<String, String>();

            HttpRequest actual = new HttpRequest(method, url, parameters, authorization, requestHeaders);
            assertThat(new URL(actual.getURL()), is(pathOf("/foo/bar")));
            assertThat(new URL(actual.getURL()), hasParameter("access_token", "access_token"));
View Full Code Here

Examples of facebook4j.auth.OAuthAuthorization

            parameters[0] = new HttpParameter("hoge", "1");
            ConfigurationBuilder cb = new ConfigurationBuilder()
                                        .setAppSecretProofEnabled(true)
                                        .setOAuthAppSecret("1234567890123456")
                                        .setOAuthAccessToken("access_token");
            OAuthAuthorization authorization = new OAuthAuthorization(cb.build());
            Map<String, String> requestHeaders = new HashMap<String, String>();

            HttpRequest actual = new HttpRequest(method, url, parameters, authorization, requestHeaders);
            assertThat(actual.getURL(), is("https://graph.facebook.com/foo/bar"));
            assertThat(actual.getParameters().length, is(3));
View Full Code Here

Examples of facebook4j.auth.OAuthAuthorization

        String appId = conf.getOAuthAppId();
        String appSecret = conf.getOAuthAppSecret();
        if (null == appId && null == appSecret) {
            throw new IllegalStateException("App id and App secret not supplied.");
        }
        OAuthAuthorization oauth = new OAuthAuthorization(conf);
        oauth.setOAuthAccessToken(accessToken);
        return getInstance(oauth);
    }
View Full Code Here

Examples of facebook4j.auth.OAuthAuthorization

    protected Facebook createFacebook() {
        ConfigurationBuilder cb = new ConfigurationBuilder();
        cb.setOAuthAppId(p.getProperty("oauth.appId")).setOAuthAppSecret(p.getProperty("oauth.appSecret"));
        cb.setOAuthAccessToken(p.getProperty("oauth.accessToken"));
        Authorization auth = new OAuthAuthorization(cb.build());
        return new FacebookFactory().getInstance(auth);
    }
View Full Code Here

Examples of facebook4j.auth.OAuthAuthorization

    }

    private HttpParameter[] setAppSecretProofParameter(HttpParameter[] parameters, Authorization authorization) {
        if (authorization == null) return parameters;
        if (!(authorization instanceof OAuthAuthorization)) return parameters;
        OAuthAuthorization oAuthAuthorization = (OAuthAuthorization) authorization;
        if (!oAuthAuthorization.isAppSecretProofEnabled()) return parameters;
        String appSecretProof = oAuthAuthorization.generateAppSecretProof();
        return HttpParameter.merge(parameters,  new HttpParameter("appsecret_proof", appSecretProof));
    }
View Full Code Here

Examples of twitter4j.auth.OAuthAuthorization

            // try to populate OAuthAuthorization if available in the configuration
            String consumerKey = conf.getOAuthConsumerKey();
            String consumerSecret = conf.getOAuthConsumerSecret();
            // try to find oauth tokens in the configuration
            if (consumerKey != null && consumerSecret != null) {
                OAuthAuthorization oauth = new OAuthAuthorization(conf);
                String accessToken = conf.getOAuthAccessToken();
                String accessTokenSecret = conf.getOAuthAccessTokenSecret();
                if (accessToken != null && accessTokenSecret != null) {
                    oauth.setOAuthAccessToken(new AccessToken(accessToken, accessTokenSecret));
                }
                this.auth = oauth;
            } else {
                this.auth = NullAuthorization.getInstance();
            }
View Full Code Here

Examples of twitter4j.auth.OAuthAuthorization

        }
        if (null == consumerSecret) {
            throw new NullPointerException("consumer secret is null");
        }
        if (auth instanceof NullAuthorization) {
            OAuthAuthorization oauth = new OAuthAuthorization(conf);
            oauth.setOAuthConsumer(consumerKey, consumerSecret);
            auth = oauth;
        } else if (auth instanceof BasicAuthorization) {
            XAuthAuthorization xauth = new XAuthAuthorization((BasicAuthorization) auth);
            xauth.setOAuthConsumer(consumerKey, consumerSecret);
            auth = xauth;
View Full Code Here

Examples of twitter4j.auth.OAuthAuthorization

        if (auth instanceof BasicAuthorization) {
            BasicAuthorization basicAuth = (BasicAuthorization) auth;
            auth = AuthorizationFactory.getInstance(conf);
            if (auth instanceof OAuthAuthorization) {
                this.auth = auth;
                OAuthAuthorization oauthAuth = (OAuthAuthorization) auth;
                oauthAccessToken = oauthAuth.getOAuthAccessToken(basicAuth.getUserId(), basicAuth.getPassword());
            } else {
                throw new IllegalStateException("consumer key / secret combination not supplied.");
            }
        } else {
            if (auth instanceof XAuthAuthorization) {
                XAuthAuthorization xauth = (XAuthAuthorization) auth;
                this.auth = xauth;
                OAuthAuthorization oauthAuth = new OAuthAuthorization(conf);
                oauthAuth.setOAuthConsumer(xauth.getConsumerKey(), xauth.getConsumerSecret());
                oauthAccessToken = oauthAuth.getOAuthAccessToken(xauth.getUserId(), xauth.getPassword());
            } else {
                oauthAccessToken = getOAuth().getOAuthAccessToken();
            }
        }
        screenName = oauthAccessToken.getScreenName();
View Full Code Here

Examples of twitter4j.auth.OAuthAuthorization

        String consumerKey = conf.getOAuthConsumerKey();
        String consumerSecret = conf.getOAuthConsumerSecret();
        if (null == consumerKey && null == consumerSecret) {
            throw new IllegalStateException("Consumer key and Consumer secret not supplied.");
        }
        OAuthAuthorization oauth = new OAuthAuthorization(conf);
        oauth.setOAuthConsumer(consumerKey, consumerSecret);
        oauth.setOAuthAccessToken(accessToken);
        return new AsyncTwitterImpl(conf, oauth);
    }
View Full Code Here

Examples of twitter4j.auth.OAuthAuthorization

        String consumerKey = conf.getOAuthConsumerKey();
        String consumerSecret = conf.getOAuthConsumerSecret();
        if (null == consumerKey && null == consumerSecret) {
            throw new IllegalStateException("Consumer key and Consumer secret not supplied.");
        }
        OAuthAuthorization oauth = new OAuthAuthorization(conf);
        oauth.setOAuthAccessToken(accessToken);
        return getInstance(conf, oauth);
    }
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.