From 865f6e3b886a5f60e94c5ff65d483b2891086e44 Mon Sep 17 00:00:00 2001 From: Angelica Ochoa Date: Mon, 11 Feb 2019 11:59:59 -0500 Subject: [PATCH] Use OAuth2Operations to fetch user email Signed-off-by: Angelica Ochoa --- .../googleplus/GoogleplusConnectionFactory.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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..63140df8257 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,12 +32,13 @@ 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 * @@ -57,10 +58,9 @@ public GoogleplusConnectionFactory(String clientId, String clientSecret) { */ @Override protected String extractProviderUserId(AccessGrant accessGrant) { - Google api = ((GoogleServiceProvider)getServiceProvider()).getApi(accessGrant.getAccessToken()); - UserProfile userProfile = getApiAdapter().fetchUserProfile(api); - return userProfile.getEmail(); + Google api = ((GoogleServiceProvider)getServiceProvider()).getApi(accessGrant.getAccessToken()); + OAuth2Operations op = api.oauth2Operations(); + return op.getUserinfo().getEmail(); } - }