/** * Returns {@link Facebook} instance. If needed, creates one from configuration. * @return {@link Facebook} instance */ public Facebook getFacebook() throws FacebookException { 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 facebook = factory.getInstance(); // verify the access token facebook.getOAuthAccessToken(); LOG.debug("Login with app id, secret and token, all APIs accessible"); } } return facebook; }
/** * Returns a instance associated with the configuration bound to this factory. * * @return default singleton instance */ public Facebook getInstance() { return getInstance(AuthorizationFactory.getInstance(conf)); }
/** * Returns a instance associated with the configuration bound to this factory. * * @return default singleton instance */ public Facebook getInstance() { return getInstance(AuthorizationFactory.getInstance(conf)); }
FacebookFactory ff = new FacebookFactory(configuration); facebook = ff.getInstance();
/** * Returns a instance associated with the configuration bound to this factory. * * @return default singleton instance */ public Facebook getInstance() { return getInstance(AuthorizationFactory.getInstance(conf)); }
protected Facebook getFacebookClient() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true) .setOAuthAppId(configuration.getOauth().getAppId()) .setOAuthAppSecret(configuration.getOauth().getAppSecret()) .setOAuthAccessToken(configuration.getOauth().getUserAccessToken()) .setOAuthPermissions(ALL_PERMISSIONS) .setJSONStoreEnabled(true); FacebookFactory ff = new FacebookFactory(cb.build()); return ff.getInstance(); }
/** * Returns a OAuth Authenticated instance.<br> * app Id and app Secret must be provided by facebook4j.properties, or system properties.<br> * Unlike {@link Facebook#setOAuthAccessToken(facebook4j.auth.AccessToken)}, this factory method potentially returns a cached instance. * * @param accessToken access token * @return an instance * @since Twitter4J 2.1.9 */ public Facebook getInstance(AccessToken accessToken) { 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); }
protected Facebook getFacebookClient() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true) .setOAuthAppId(configuration.getOauth().getAppId()) .setOAuthAppSecret(configuration.getOauth().getAppSecret()) .setOAuthAccessToken(configuration.getOauth().getUserAccessToken()) .setOAuthPermissions(ALL_PERMISSIONS) .setJSONStoreEnabled(true) .setClientVersion("v1.0"); FacebookFactory ff = new FacebookFactory(cb.build()); return ff.getInstance(); }
/** * Returns a OAuth Authenticated instance.<br> * app Id and app Secret must be provided by facebook4j.properties, or system properties.<br> * Unlike {@link Facebook#setOAuthAccessToken(facebook4j.auth.AccessToken)}, this factory method potentially returns a cached instance. * * @param accessToken access token * @return an instance * @since Twitter4J 2.1.9 */ public Facebook getInstance(AccessToken accessToken) { 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); }
protected Facebook getFacebookClient() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true) .setOAuthAppId(facebookUserInformationConfiguration.getOauth().getAppId()) .setOAuthAppSecret(facebookUserInformationConfiguration.getOauth().getAppSecret()) .setOAuthAccessToken(facebookUserInformationConfiguration.getOauth().getUserAccessToken()) .setOAuthPermissions(ALL_PERMISSIONS) .setJSONStoreEnabled(true) .setClientVersion("v1.0"); FacebookFactory ff = new FacebookFactory(cb.build()); return ff.getInstance(); }
/** * Returns a OAuth Authenticated instance.<br> * app Id and app Secret must be provided by facebook4j.properties, or system properties.<br> * Unlike {@link Facebook#setOAuthAccessToken(facebook4j.auth.AccessToken)}, this factory method potentially returns a cached instance. * * @param accessToken access token * @return an instance * @since Twitter4J 2.1.9 */ public Facebook getInstance(AccessToken accessToken) { 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); }
protected Facebook getFacebookClient() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true) .setOAuthAppId(configuration.getOauth().getAppId()) .setOAuthAppSecret(configuration.getOauth().getAppSecret()) .setOAuthAccessToken(configuration.getOauth().getUserAccessToken()) .setOAuthPermissions(ALL_PERMISSIONS) .setJSONStoreEnabled(true) .setClientVersion("v1.0"); FacebookFactory ff = new FacebookFactory(cb.build()); return ff.getInstance(); }
/** * Gets a Facebook client. If multiple authenticated users for this app are available * it will rotate through the users oauth credentials * @return client */ protected Facebook getNextFacebookClient() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true); cb.setOAuthPermissions(READ_ONLY); cb.setOAuthAppId(this.config.getOauth().getAppId()); cb.setOAuthAppSecret(this.config.getOauth().getAppSecret()); if (this.authTokens.numAvailableTokens() > 0) { cb.setOAuthAccessToken(this.authTokens.getNextAvailableToken()); } else { cb.setOAuthAccessToken(this.config.getOauth().getAppAccessToken()); LOGGER.debug("appAccessToken : {}", this.config.getOauth().getAppAccessToken()); } cb.setJSONStoreEnabled(true); if (StringUtils.isNotEmpty(config.getVersion())) { cb.setRestBaseURL("https://graph.facebook.com/" + config.getVersion() + "/"); } LOGGER.debug("appId : {}", this.config.getOauth().getAppId()); LOGGER.debug("appSecret: {}", this.config.getOauth().getAppSecret()); FacebookFactory ff = new FacebookFactory(cb.build()); return ff.getInstance(); }