I am able to get a connection going to facebook and twitter -- however, the problem is that once I connect and authenticate with the provider that instead of being sent back to my URL that I am specifying in my connect controller, it is being sent back to my application with the suffix /connect/{provider}. What am I missing in the configuration below that is keeping it from sending it to the application URL that I am specifying in the controller? Any help is greatly appreciated it.
Code:
@Configuration
public class SocialConfig implements InitializingBean {
private static Logger log = Logger.getLogger(LoginController.class);
@Inject
PropertiesFactoryBean appProperties;
@Inject
DataSource dataSource;
@Bean
public ConnectionFactoryLocator connectionFactoryLocator() {
String facebookClientId = "";
String facebookClientSecret = "";
String twitterConsumerKey = "";
String twitterConsumerSecret = "";
try {
facebookClientId = appProperties.getObject().getProperty(
"facebook.clientId");
facebookClientSecret = appProperties.getObject().getProperty(
"facebook.clientSecret");
twitterConsumerKey = appProperties.getObject().getProperty(
"twitter.consumerKey");
twitterConsumerSecret = appProperties.getObject().getProperty(
"twitter.consumerSecret");
} catch (IOException e) {
}
log.info("getting connectionFactoryLocator");
ConnectionFactoryRegistry registry = new ConnectionFactoryRegistry();
registry.addConnectionFactory(new FacebookConnectionFactory(
facebookClientId, facebookClientSecret));
registry.addConnectionFactory(new TwitterConnectionFactory(
twitterConsumerKey, twitterConsumerSecret));
return registry;
}
/**
* Singleton data access object providing access to connections across all
* users.
*/
@Bean
public UsersConnectionRepository usersConnectionRepository() {
return new JdbcUsersConnectionRepository(dataSource,
connectionFactoryLocator(), Encryptors.noOpText());
// return usersConnectionRepositiory;
}
@Bean
@Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
public ConnectionRepository connectionRepository() {
Authentication authentication = SecurityContextHolder.getContext()
.getAuthentication();
if (authentication == null) {
throw new IllegalStateException(
"Unable to get a ConnectionRepository: no user signed in");
}
return usersConnectionRepository().createConnectionRepository(
authentication.getName());
}
@Bean
@Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
public Facebook facebook() {
Facebook api = connectionRepository().getPrimaryConnection(
Facebook.class).getApi();
// socialContext().setFacebook(api);
// socialContext().setCookies(request.getCookies());
return api;
}
@Bean
@Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
public Twitter twitter() {
Twitter api = connectionRepository()
.getPrimaryConnection(Twitter.class).getApi();
// socialContext().setTwitter(api);
// socialContext().setCookies(request.getCookies());
return api;
}
// @Bean
// public SocialContext socialContext() {
// SocialContext socialContext = new
// SocialContext(usersConnectionRepository());
// return socialContext;
// }
@Bean
public ConnectController connectController() {
ConnectController connectController = new ConnectController(
connectionFactoryLocator(), connectionRepository());
// connectController.addInterceptor(new FacebookInterceptor());
connectController.setApplicationUrl("http://{myurl}:8080/market/secure/callback");
return connectController;
}
@Bean
public ProviderSignInController providerSignInController() {
return new ProviderSignInController(connectionFactoryLocator(),
usersConnectionRepository(), new SimpleSignInAdapter());
}
@Override
public void afterPropertiesSet() throws Exception {
}
}