org.springframework.social.facebook.api.Facebook Java Examples

The following examples show how to use org.springframework.social.facebook.api.Facebook. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConfigAwareConnectionFactoryLocatorTest.java    From engine with GNU General Public License v3.0 6 votes vote down vote up
@Override
@Before
public void setUp() throws Exception {
    super.setUp();

    CacheTemplateMockUtils.setUpWithNoCaching(cacheTemplate);

    ConfigurationParser<?> configParserStub = new FacebookConnectionFactoryConfigParser() {

        @Override
        protected ConnectionFactory<Facebook> createFacebookConnectionFactory(String appId, String appSecret) {
            return new FacebookConnectionFactoryStub(appId, appSecret);
        }

    };

    locator = new ConfigAwareConnectionFactoryLocator();
    locator.setCacheTemplate(cacheTemplate);
    locator.setDefaultLocator(new ConnectionFactoryRegistry());
    locator.setConfigParsers(Arrays.<ConfigurationParser<?>>asList(configParserStub));
}
 
Example #2
Source File: FacebookAutoConfiguration.java    From spring-security-oauth2-boot with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(Facebook.class)
@Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
public Facebook facebook(ConnectionRepository repository) {
	Connection<Facebook> connection = repository.findPrimaryConnection(Facebook.class);
	return connection != null ? connection.getApi() : null;
}
 
Example #3
Source File: CustomFacebookServiceProvider.java    From OAuth-2.0-Cookbook with MIT License 5 votes vote down vote up
@Override
public Facebook getApi(String accessToken) {
	FacebookTemplate template = new FacebookTemplate(accessToken, appNamespace);
	template.setApiVersion(apiVersion);

	return template;
}
 
Example #4
Source File: FacebookConfiguration.java    From OAuth-2.0-Cookbook with MIT License 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(Facebook.class)
@Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
public Facebook facebook(ConnectionRepository repository) {
	Connection<Facebook> connection = repository
			.findPrimaryConnection(Facebook.class);
	return connection != null ? connection.getApi() : null;
}
 
Example #5
Source File: FacebookConnectionFactoryConfigParser.java    From engine with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ConnectionFactory<Facebook> parse(HierarchicalConfiguration config) throws ConfigurationException {
    String appId = config.getString(FACEBOOK_CONNECTION_FACTORY_APP_ID_KEY);
    String appSecret = config.getString(FACEBOOK_CONNECTION_FACTORY_APP_SECRET_KEY);

    if (StringUtils.isNotEmpty(appId) && StringUtils.isNotEmpty(appSecret)) {
        return createFacebookConnectionFactory(appId, appSecret);
    } else {
        return null;
    }
}
 
Example #6
Source File: ConfigAwareConnectionFactoryLocatorTest.java    From engine with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testGetConnectionFactoryWithApiType() throws Exception {
    FacebookConnectionFactoryStub factory = (FacebookConnectionFactoryStub)locator.getConnectionFactory(Facebook.class);

    assertNotNull(factory);
    assertEquals(config.getString(SOCIAL_CONNECTIONS_KEY + "." + FACEBOOK_CONNECTION_FACTORY_APP_ID_KEY), factory.appId);
    assertEquals(config.getString(SOCIAL_CONNECTIONS_KEY + "." + FACEBOOK_CONNECTION_FACTORY_APP_SECRET_KEY), factory.appSecret);
}
 
Example #7
Source File: FacebookProviderConfig.java    From AIDR with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected ConnectInterceptor<Facebook> getConnectInterceptor() {	
      if( facebookConnectInterceptor == null ) {
               facebookConnectInterceptor = new FacebookConnectInterceptor();
       }
       return facebookConnectInterceptor;
}
 
Example #8
Source File: FacebookProviderConfig.java    From AIDR with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected ConnectInterceptor<Facebook> getConnectInterceptor() {	
      if( facebookConnectInterceptor == null ) {
               facebookConnectInterceptor = new FacebookConnectInterceptor();
       }
       return facebookConnectInterceptor;
}
 
Example #9
Source File: StatelessSocialConfig.java    From boot-stateless-social with MIT License 4 votes vote down vote up
@Bean
@Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
public Facebook facebook(ConnectionRepository repository) {
	Connection<Facebook> connection = repository.findPrimaryConnection(Facebook.class);
	return connection != null ? connection.getApi() : null;
}
 
Example #10
Source File: FacebookConnectionFactoryConfigParser.java    From engine with GNU General Public License v3.0 4 votes vote down vote up
protected ConnectionFactory<Facebook> createFacebookConnectionFactory(String appId, String appSecret) {
    return new FacebookConnectionFactory(appId, appSecret);
}
 
Example #11
Source File: ConfigAwareConnectionFactoryLocatorTest.java    From engine with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Connection<Facebook> createConnection(ConnectionData data) {
    return null;
}
 
Example #12
Source File: FacebookProviderConfig.java    From AIDR with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected ConnectionFactory<Facebook> createConnectionFactory() {
	FacebookConnectionFactory facebookConnectionFactory = new FacebookConnectionFactory(facebookConsumerKey, facebookConsumerSecret);
	facebookConnectionFactory.setScope("email");
	return facebookConnectionFactory;
}
 
Example #13
Source File: FacebookProviderConfig.java    From AIDR with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected ConnectionFactory<Facebook> createConnectionFactory() {
	FacebookConnectionFactory facebookConnectionFactory = new FacebookConnectionFactory(facebookConsumerKey, facebookConsumerSecret);
	facebookConnectionFactory.setScope("email");
	return facebookConnectionFactory;
}