#NEWLINE# def _oauth1_init( self , provider , auth_urls ) : #NEWLINE# #INDENT# 'Initiates OAuth 1.0 dance' #NEWLINE# ( key , secret ) = self . _get_consumer_info_for ( provider ) #NEWLINE# callback_url = self . _callback_uri_for ( provider ) #NEWLINE# token_request_url = auth_urls . get ( 'request' , None ) #NEWLINE# auth_url = auth_urls . get ( 'auth' , None ) #NEWLINE# _parse = getattr ( self , self . TOKEN_RESPONSE_PARSERS [ provider ] , None ) #NEWLINE# if ( not ( key or secret or token_request_url or auth_url or callback_url or _parse ) ) : #NEWLINE# #INDENT# raise Exception ( ( 'Provider %s is not supported' % provider ) ) #NEWLINE# #UNINDENT# client = self . _oauth1_client ( consumer_key = key , consumer_secret = secret ) #NEWLINE# ( resp , content ) = client . request ( auth_urls [ 'request' ] , 'GET' ) #NEWLINE# if ( resp . status != 200 ) : #NEWLINE# #INDENT# raise Exception ( ( 'Could not fetch a valid response from %s' % provider ) ) #NEWLINE# #UNINDENT# request_token = _parse ( content ) #NEWLINE# if ( not request_token . get ( 'oauth_token' , None ) ) : #NEWLINE# #INDENT# raise Exception ( ( "Couldn't get a valid token from %s\n%s" % ( provider , str ( request_token ) ) ) ) #NEWLINE# #UNINDENT# target_url = auth_urls [ 'auth' ] . format ( urlencode ( { #NEWLINE# #INDENT# 'oauth_token' : request_token . get ( 'oauth_token' , None ) , #NEWLINE# 'oauth_callback' : callback_url , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# logging . debug ( ( 'Redirecting user to %s' % target_url ) ) #NEWLINE# self . session [ 'req_token' ] = request_token #NEWLINE# self . redirect ( target_url )