#NEWLINE# @ gen . engine #NEWLINE# def _GetUserInfo( self , device_dict , refresh_token , response ) : #NEWLINE# #INDENT# 'Parses the google access token from the JSON response body. Gets user data via OAUTH2\n    with access token.\n    ' #NEWLINE# tokens = www_util . ParseJSONResponse ( response ) #NEWLINE# assert tokens , 'unable to fetch access token' #NEWLINE# access_token = tokens [ 'access_token' ] #NEWLINE# expires = tokens [ 'expires_in' ] #NEWLINE# if ( tokens . has_key ( 'refresh_token' ) and ( not refresh_token ) ) : #NEWLINE# #INDENT# refresh_token = tokens [ 'refresh_token' ] #NEWLINE# #UNINDENT# assert access_token , 'no access token was provided' #NEWLINE# url = ( ( AuthGoogleHandler . _OAUTH2_USERINFO_URL + '?' ) + urllib . urlencode ( { #NEWLINE# #INDENT# 'access_token' : access_token , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# http_client = httpclient . AsyncHTTPClient ( ) #NEWLINE# response = ( yield gen . Task ( http_client . fetch , url ) ) #NEWLINE# user_dict = www_util . ParseJSONResponse ( response ) #NEWLINE# assert user_dict , 'unable to fetch user data' #NEWLINE# assert ( 'phone' not in user_dict ) , user_dict #NEWLINE# assert ( 'email' in user_dict ) , user_dict #NEWLINE# user_dict [ 'email' ] = Identity . CanonicalizeEmail ( user_dict [ 'email' ] ) #NEWLINE# if ( not user_dict . get ( 'verified_email' , False ) ) : #NEWLINE# #INDENT# raise web . HTTPError ( 403 , ( _CANNOT_USE_UNVERIFIED_EMAIL % user_dict [ 'email' ] ) ) #NEWLINE# #UNINDENT# ident_dict = { #NEWLINE# #INDENT# 'key' : ( 'Email:%s' % user_dict [ 'email' ] ) , #NEWLINE# 'authority' : 'Google' , #NEWLINE# 'refresh_token' : refresh_token , #NEWLINE# 'access_token' : access_token , #NEWLINE# 'expires' : ( util . GetCurrentTimestamp ( ) + expires ) , #NEWLINE# #UNINDENT# } #NEWLINE# self . _AuthUser ( user_dict , ident_dict , device_dict )