#NEWLINE# def getUser( self , token ) : #NEWLINE# #INDENT# headers = { #NEWLINE# #INDENT# 'Authorization' : ' ' . join ( ( token [ 'token_type' ] , token [ 'access_token' ] ) ) , #NEWLINE# #UNINDENT# } #NEWLINE# query = urllib . parse . urlencode ( { #NEWLINE# #INDENT# 'fields' : ',' . join ( self . _API_USER_FIELDS ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# resp = self . _getJson ( method = 'GET' , url = ( '%s?%s' % ( self . _API_USER_URL , query ) ) , headers = headers ) #NEWLINE# oauthId = resp . get ( 'id' ) #NEWLINE# if ( not oauthId ) : #NEWLINE# #INDENT# raise RestException ( 'Google Plus did not return a user ID.' , code = 502 ) #NEWLINE# #UNINDENT# emails = [ email . get ( 'value' ) for email in resp . get ( 'emails' , [ ] ) if ( email . get ( 'type' ) == 'account' ) ] #NEWLINE# if ( not lastName ) : #NEWLINE# #INDENT# emails = [ email . get ( 'value' ) for email in resp . get ( 'emails' , [ ] ) ] #NEWLINE# #UNINDENT# if emails : #NEWLINE# #INDENT# email = emails [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise RestException ( 'This Google Plus user has no available email address.' , code = 502 ) #NEWLINE# #UNINDENT# firstName = resp . get ( 'name' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) . get ( 'givenName' , '' ) #NEWLINE# lastName = resp . get ( 'name' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) . get ( 'familyName' , '' ) #NEWLINE# user = self . _createOrReuseUser ( oauthId , email , firstName , lastName ) #NEWLINE# return user