Skip to content

Instantly share code, notes, and snippets.

@pjagielski
Created April 10, 2012 21:40
Show Gist options
  • Save pjagielski/2354774 to your computer and use it in GitHub Desktop.
Save pjagielski/2354774 to your computer and use it in GitHub Desktop.
getProfile
OAuthProfile getProfile(OAuthService authService, Token accessToken) {
OAuthRequest request = new OAuthRequest(Verb.GET, 'https://www.googleapis.com/oauth2/v1/userinfo')
authService.signRequest(accessToken, request)
def response = request.send()
def user = JSON.parse(response.body)
def login = "${user.given_name}.${user.family_name}".toLowerCase()
new OAuthProfile(username: login, email: user.email, uid: user.id, picture: user.picture)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment