#NEWLINE# @ handler . asynchronous ( datastore = True ) #NEWLINE# @ gen . engine #NEWLINE# def get( self , action ) : #NEWLINE# #INDENT# "GET is used when authenticating via the web application. If code isn't supplied in URL\n    params, redirects to Google with a request for authentication. Google redirects to this\n    URL again on successful authentication with a code which is then used to authorize user\n    information and contacts.\n    " #NEWLINE# self . _StartInteractiveRequest ( action ) #NEWLINE# if ( not self . get_argument ( 'code' , False ) ) : #NEWLINE# #INDENT# url = AuthGoogleHandler . _OAUTH2_AUTH_URL #NEWLINE# args = { #NEWLINE# #INDENT# 'client_id' : self . settings [ 'google_client_id' ] , #NEWLINE# 'redirect_uri' : ( 'https://%s/%s/google' % ( self . request . host , action ) ) , #NEWLINE# 'response_type' : 'code' , #NEWLINE# 'access_type' : 'offline' , #NEWLINE# 'approval_prompt' : 'force' , #NEWLINE# 'scope' : AuthGoogleHandler . _OAUTH2_SCOPE , #NEWLINE# #UNINDENT# } #NEWLINE# self . redirect ( ( ( url + '?' ) + urllib . urlencode ( args ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# url = AuthGoogleHandler . _OAUTH2_ACCESS_TOKEN_URL #NEWLINE# args = { #NEWLINE# #INDENT# 'client_id' : self . settings [ 'google_client_id' ] , #NEWLINE# 'client_secret' : self . settings [ 'google_client_secret' ] , #NEWLINE# 'redirect_uri' : ( 'https://%s/%s/google' % ( self . request . host , action ) ) , #NEWLINE# 'code' : self . get_argument ( 'code' ) , #NEWLINE# 'grant_type' : 'authorization_code' , #NEWLINE# #UNINDENT# } #NEWLINE# http_client = httpclient . AsyncHTTPClient ( ) #NEWLINE# response = ( yield gen . Task ( http_client . fetch , url , method = 'POST' , body = urllib . urlencode ( args ) ) ) #NEWLINE# self . _GetUserInfo ( None , None , response )