Skip to content

Commit

Permalink
Use OAuth2Operations to fetch user email
Browse files Browse the repository at this point in the history
Signed-off-by: Angelica Ochoa <[email protected]>
  • Loading branch information
ao508 committed Feb 11, 2019
1 parent 2324d12 commit 865f6e3
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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();
}


}

0 comments on commit 865f6e3

Please sign in to comment.