Comments (11)
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.
what workaround for this problem?
from spring-social-google.
@MikhailErofeev Did you find any workaround to this problem?
from spring-social-google.
@raoravik nope, switch to twitter :)
from spring-social-google.
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.
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.
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.
Was there any resolution or workaround to this issue? The code same above for CustomGoogleConnectionFactory does not resolve the issue.
from spring-social-google.
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.
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.
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)
- Get a release out the door! HOT 12
- Is it possible to return drive files in sorted order?
- 1.2.x Release Tracking
- add support for google people api HOT 1
- New release for Maven repository? HOT 1
- Question: Google+ sunsetting effects? HOT 12
- Can we have the latest release 1.1.3 deployed to maven central as 1.1.3.RELEASE HOT 1
- Account email null after fetchUserProfile()
- Google Plus Api 'Person' Class Bug HOT 3
- I/O Error Attempted read from closed stream.
- Google OAuth2 Authorization error
- build fails HOT 3
- Add support for download exported files from google docs
- Tag and release from Maven Central HOT 9
- Add field circledByCount on Person.java class
- Photo quality is extremely low
- Asking for refresh_token and dealing with fetching new access_token when it expired HOT 1
- google.plusOperations().getGoogleProfile() throws a 403 exception after successful OAuth2 login HOT 1
- Update Jackson to 2.6+ to be compatible with Spring 4.3.5
- Missing UrlType enum constant WEBSITE
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-social-google.