diff --git a/security/security-spring/src/main/java/org/cbioportal/security/spring/authentication/googleplus/GoogleplusConnectionFactory.java b/security/security-spring/src/main/java/org/cbioportal/security/spring/authentication/googleplus/GoogleplusConnectionFactory.java index 4a62f9d1dd5..f40256881bb 100644 --- a/security/security-spring/src/main/java/org/cbioportal/security/spring/authentication/googleplus/GoogleplusConnectionFactory.java +++ b/security/security-spring/src/main/java/org/cbioportal/security/spring/authentication/googleplus/GoogleplusConnectionFactory.java @@ -32,35 +32,33 @@ package org.cbioportal.security.spring.authentication.googleplus; -import org.springframework.social.connect.UserProfile; import org.springframework.social.connect.support.OAuth2ConnectionFactory; import org.springframework.social.google.api.Google; import org.springframework.social.google.connect.GoogleAdapter; import org.springframework.social.google.connect.GoogleServiceProvider; import org.springframework.social.oauth2.AccessGrant; +import org.springframework.social.google.api.oauth2.OAuth2Operations; + /** * @author criscuof * */ public class GoogleplusConnectionFactory extends OAuth2ConnectionFactory { - - - - public GoogleplusConnectionFactory(String clientId, String clientSecret) { - super("google", new GoogleServiceProvider(clientId, clientSecret), - new GoogleAdapter()); - } - /* - * modification of original factory class to support using the user's email address as his/her id - * original method utilized the google id, a numeric string - */ - @Override - protected String extractProviderUserId(AccessGrant accessGrant) { - Google api = ((GoogleServiceProvider)getServiceProvider()).getApi(accessGrant.getAccessToken()); - UserProfile userProfile = getApiAdapter().fetchUserProfile(api); - return userProfile.getEmail(); - } + public GoogleplusConnectionFactory(String clientId, String clientSecret) { + super("google", new GoogleServiceProvider(clientId, clientSecret), + new GoogleAdapter()); + } + /** + * modification of original factory class to support using the user's email address as his/her id + * original method utilized the google id, a numeric string + */ + @Override + protected String extractProviderUserId(AccessGrant accessGrant) { + Google api = ((GoogleServiceProvider)getServiceProvider()).getApi(accessGrant.getAccessToken()); + OAuth2Operations op = api.oauth2Operations(); + return op.getUserinfo().getEmail(); + } }