Package facebook4j.auth

Examples of facebook4j.auth.AccessToken


        System.out.println("oauthCode: " + oauthCode);

        try {
            // アクセストークンの取得
            AccessToken accessToken = facebook.getOAuthAccessToken(oauthCode);
            String tokenString = accessToken.getToken();

            // アクセスを2ヶ月有効トークンに変更
            Map<String, String> params = new HashMap<String, String>();
            params.put("client_id", Constants.FACEBOOK_APP_API_KEY);
            params.put("client_secret", Constants.FACEBOOK_APP_API_SECRET);
            params.put("grant_type", "fb_exchange_token");
            params.put("fb_exchange_token", tokenString);

            RawAPIResponse apiResponse = facebook.callGetAPI("/oauth/access_token", params);
            String response = apiResponse.asString();
            AccessToken newAccessToken = new AccessToken(response);
            String newToken = newAccessToken.getToken();

            if(newToken != null) {
                User facebookUser = facebook.getMe();

                loginUserModel.setFacebookAccessToken(new Text(newToken));
View Full Code Here


    private Facebook getFaceBookObject(UserModel userModel) throws Exception {

        Facebook facebook = new FacebookFactory().getInstance();
        facebook.setOAuthAppId(Constants.FACEBOOK_APP_API_KEY, Constants.FACEBOOK_APP_API_SECRET);
        facebook.setOAuthPermissions(Constants.FACEBOOK_APP_API_PERMISSIONS);
        facebook.setOAuthAccessToken(new AccessToken(userModel.getFacebookAccessTokenString()));

        return facebook;
    }
View Full Code Here

            if (accessToken == null) {
                facebook.getOAuthAppAccessToken();
            }
        }
        if (accessToken != null) {
            facebook.setOAuthAccessToken(new AccessToken(accessToken));
        }
        if (appSecretProofEnabled != null) {
            facebook.setAppSecretProofEnabled(Boolean.valueOf(appSecretProofEnabled));
        }
View Full Code Here

                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

    @Before
    public void setUp() throws Exception {
        Configuration conf = new ConfigurationBuilder().setJSONStoreEnabled(true).build();
        facebook = MockFacebookFactory.create(conf);
        facebook.setOAuthAppId("mock", "json");
        facebook.setOAuthAccessToken(new AccessToken("required"));
    }
View Full Code Here

    // Added method by Facebook4J
    private HttpParameter[] setAccessTokenParameter(HttpParameter[] parameters, Authorization authorization) {
        if (authorization == null) return parameters;
        if (!(authorization instanceof OAuthAuthorization)) return parameters;
        AccessToken accessToken = ((OAuthAuthorization) authorization).getOAuthAccessToken();
        if (accessToken == null) return parameters;
        return HttpParameter.merge(parameters,  new HttpParameter("access_token", accessToken.getToken()));
    }
View Full Code Here

TOP

Related Classes of facebook4j.auth.AccessToken

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.