Giter VIP home page Giter VIP logo

Comments (11)

vedab avatar vedab commented on May 26, 2024

Property "scope" has to be added to the GoogleConnectionFactory. The values for the "scope" parameters are specified here: https://developers.google.com/accounts/docs/OAuth2Login#scope-param

XML config:
<bean class="org.springframework.social.google.connect.GoogleConnectionFactory">
   <constructor-arg value="${google.clientId}" />
   <constructor-arg value="${google.clientSecret}" />
   <property name="scope" value="profile" />
</bean>

Java Config:
GoogleConnectionFactory gcf = new GoogleConnectionFactory(env.getProperty("google.clientId"), env.getProperty("google.clientSecret"));
gcf.setScope("profile");
connectionFactoryConfigurer.addConnectionFactory(gcf);

from spring-social-google.

MikhailErofeev avatar MikhailErofeev commented on May 26, 2024

what workaround for this problem?

from spring-social-google.

raoravik avatar raoravik commented on May 26, 2024

@MikhailErofeev Did you find any workaround to this problem?

from spring-social-google.

MikhailErofeev avatar MikhailErofeev commented on May 26, 2024

@raoravik nope, switch to twitter :)

from spring-social-google.

raoravik avatar raoravik commented on May 26, 2024

Well, I did manage to write a custom class and ensure the scope is sent. However, the flow is still not correct. After logging through Google account, it takes me to the register page where Name fields are populated but I still need to enter the email and password. :( Trying to figure out the issue..

from spring-social-google.

raoravik avatar raoravik commented on May 26, 2024

Here is the code:

import org.springframework.social.google.connect.GoogleConnectionFactory;

public class CustomGoogleConnectionFactory extends GoogleConnectionFactory {
    private String scope = "profile";

    public CustomGoogleConnectionFactory(String clientId, String clientSecret) {
        super(clientId, clientSecret);
    }

    public String getScope() {
        return scope;
    }

    public void setScope(String scope) {
        this.scope = scope;
    }
}

And in your SocialContext.java

CustomGoogleConnectionFactory googleConnectionFactory = new CustomGoogleConnectionFactory(
                env.getProperty("google.consumerKey"),
                env.getProperty("google.consumerSecret"));
        googleConnectionFactory.setScope("profile");
        cfConfig.addConnectionFactory(googleConnectionFactory);

from spring-social-google.

GabiAxel avatar GabiAxel commented on May 26, 2024

Are you sure you have a "scope" field in your page and that it is submitted correctly to the server? Can attach the login page source, or even better the entire application (or just the login part)?

from spring-social-google.

jharrisweinberg avatar jharrisweinberg commented on May 26, 2024

Was there any resolution or workaround to this issue? The code same above for CustomGoogleConnectionFactory does not resolve the issue.

from spring-social-google.

Tketa avatar Tketa commented on May 26, 2024

Specifying the scope directly in the login page worked for me:

<form action="<c:url value="/auth/google" />" method="POST">
            <input type="hidden" name="scope" value="profile" />
            <button type="submit" class="btn btn-lg btn-google"><i class="fa fa-google-plus"></i> | Sign Up with Google</button></a><br />  
</form>

from spring-social-google.

vauvenal5 avatar vauvenal5 commented on May 26, 2024

Using an interceptor works just fine.

public class GoogleScopeInterceptor implements ConnectInterceptor<Google> {
	@Override
	public void preConnect(ConnectionFactory<Google> connectionFactory, MultiValueMap<String, String> parameters, WebRequest request) {
		parameters.add("scope", "profile");
	}

	@Override
	public void postConnect(Connection<Google> connection, WebRequest request) {
		return;
	}	
}

and in the config:

        @Bean
	public ConnectController connectController(
			ConnectionFactoryLocator connectionFactoryLocator,
			ConnectionRepository connectionRepository) {
		ConnectController cc = new ConnectController(connectionFactoryLocator, connectionRepository);
		cc.addInterceptor(new GoogleScopeInterceptor());
		return cc;
	}

from spring-social-google.

SteChronis avatar SteChronis commented on May 26, 2024

With the following dependencies worked fine for me:

<spring.social.version>1.1.6.RELEASE</spring.social.version>

org.springframework.social
spring-social-google
1.0.0.RELEASE


org.springframework.social
spring-social-core
${spring.social.version}


org.springframework.social
spring-social-config
${spring.social.version}


org.springframework.social
spring-social-web
${spring.social.version}


org.springframework.social
spring-social-security
${spring.social.version}

from spring-social-google.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.