Spring Boot with Spring Social Google provider
Asked Answered
P

1

6

Any example how to integrate Spring Boot application with Spring Social Google (GabiAxel/spring-social-google) provider? I found this project, but it seems to be unfinished. Spring Boot explains how to get it working with Spring Facebook, Twitter, but is it the same for log in with Google?

Parhelion answered 2/9, 2015 at 12:35 Comment(1)
this is exactly what I need, but extended with Google providerParhelion
P
3

As you have mentioned in your question, you can use that project hosted on github.

You can use this dependency

In a Configuration class, you will have to extend SocialConfigurerAdapter, override the addConnectionFactories method and add GoogleConnectionFactory. For example :

@Configuration
@EnableSocial
public class SocialConfig extends SocialConfigurerAdapter {
@Override
public void addConnectionFactories(ConnectionFactoryConfigurer connectionFactoryConfigurer, Environment environment) {
    GoogleConnectionFactory googleConnectionFactory = new GoogleConnectionFactory(environment.getProperty("spring.social.google.app-id"), environment.getProperty("spring.social.google.app-secret"));
    googleConnectionFactory.setScope("https://www.googleapis.com/auth/plus.login");
    connectionFactoryConfigurer.addConnectionFactory(googleConnectionFactory);
}
@Bean
@Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
public Google google(ConnectionRepository repository) {
    Connection<Google> connection = repository.findPrimaryConnection(Google.class);
    return connection != null ? connection.getApi() : null;
}
}

You can use this along with the Spring Social examples.

Preliminaries answered 30/9, 2015 at 15:12 Comment(1)
this very similar to what I have already. I have still only /connect mapping auto-added, shouldn't I have also some /signin mappings added by Spring Boot to be able to log in?Parhelion

© 2022 - 2024 — McMap. All rights reserved.