Package facebook4j.auth

Examples of facebook4j.auth.OAuthAuthorization


    @Override
    public void setOAuthAppId(String appId, String appSecret) {
        super.setOAuthAppId(appId, appSecret);
        if (auth instanceof MockAuthorization) {
            OAuthAuthorization oauth = new OAuthAuthorization(conf);
            oauth.setOAuthAppId(appId, appSecret);
            this.auth = oauth;
        }
    }
View Full Code Here


        }
    }

    public void setAppSecretProofEnabled(boolean appSecretProofEnabled) {
        if (auth instanceof MockAuthorization) {
            OAuthAuthorization oauth = new OAuthAuthorization(conf);
            oauth.setAppSecretProofEnabled(appSecretProofEnabled);
            this.auth = oauth;
        } else
        if (auth instanceof OAuthAuthorization) {
            ((OAuthAuthorization) auth).setAppSecretProofEnabled(appSecretProofEnabled);
        }
View Full Code Here

            // try to populate OAuthAuthorization if available in the configuration
            String appId = conf.getOAuthAppId();
            String appSecret = conf.getOAuthAppSecret();
            // try to find oauth tokens in the configuration
            if (appId != null && appSecret != null) {
                OAuthAuthorization oauth = new OAuthAuthorization(conf);
                String accessToken = conf.getOAuthAccessToken();
                String callbackURL = conf.getOAuthCallbackURL();
                if (accessToken != null) {
                    if (callbackURL != null) {
                        oauth.setOAuthAccessToken(new AccessToken(accessToken, null), callbackURL);
                    } else {
                        oauth.setOAuthAccessToken(new AccessToken(accessToken, null));
                    }
                }
                this.auth = oauth;
            } else {
                this.auth = NullAuthorization.getInstance();
View Full Code Here

        }
        if (appSecret == null) {
            throw new NullPointerException("app secret is null");
        }
        if (auth instanceof NullAuthorization) {
            OAuthAuthorization oauth = new OAuthAuthorization(conf);
            oauth.setOAuthAppId(appId, appSecret);
            this.auth = oauth;
        } else
        if (auth instanceof OAuthAuthorization) {
            throw new IllegalStateException("app id/secret pair already set.");
        }
View Full Code Here

        if (facebook == null) {
            final Configuration configuration = getConfiguration();
            FacebookFactory factory = new FacebookFactory(configuration);
            if (this.oAuthAccessToken == null) {
                // app login
                facebook = factory.getInstance(new OAuthAuthorization(configuration));
                // also get the App access token
                facebook.getOAuthAppAccessToken();
                LOG.warn("Login with app id and secret, access to some APIs is restricted!");
            } else {
                // user login with token
View Full Code Here

            RequestMethod method = RequestMethod.GET;
            String url = "https://graph.facebook.com/foo/bar";
            HttpParameter[] parameters = new HttpParameter[1];
            parameters[0] = new HttpParameter("hoge", "1");
            ConfigurationBuilder cb = new ConfigurationBuilder().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

            RequestMethod method = RequestMethod.POST;
            String url = "https://graph.facebook.com/foo/bar";
            HttpParameter[] parameters = new HttpParameter[1];
            parameters[0] = new HttpParameter("hoge", "1");
            ConfigurationBuilder cb = new ConfigurationBuilder().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(2));
View Full Code Here

            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

            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

        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

TOP

Related Classes of facebook4j.auth.OAuthAuthorization

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.