#NEWLINE# def get_authentication_tokens( self , callback_url = None , force_login = False , screen_name = '' ) : #NEWLINE# #INDENT# 'Returns a dict including an authorization URL, ``auth_url``, to direct a user to\n\n        :param callback_url: (optional) Url the user is returned to after they authorize your app (web clients only)\n        :param force_login: (optional) Forces the user to enter their credentials to ensure the correct users account is authorized.\n        :param app_secret: (optional) If forced_login is set OR user is not currently logged in, Prefills the username input box of the OAuth login screen with the given value\n        :rtype: dict\n        ' #NEWLINE# if ( self . oauth_version != 1 ) : #NEWLINE# #INDENT# raise TwythonError ( 'This method can only be called when your OAuth version is 1.0.' ) #NEWLINE# #UNINDENT# request_args = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if callback_url : #NEWLINE# #INDENT# request_args [ 'oauth_callback' ] = callback_url #NEWLINE# #UNINDENT# response = self . client . get ( self . request_token_url , params = request_args ) #NEWLINE# if ( response . status_code == 401 ) : #NEWLINE# #INDENT# raise TwythonAuthError ( response . content , error_code = response . status_code ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( response . status_code != 200 ) : #NEWLINE# #INDENT# raise TwythonError ( response . content , error_code = response . status_code ) #NEWLINE# #UNINDENT# #UNINDENT# request_tokens = dict ( parse_qsl ( response . content . decode ( 'utf-8' ) ) ) #NEWLINE# if ( not request_tokens ) : #NEWLINE# #INDENT# raise TwythonError ( 'Unable to decode request tokens.' ) #NEWLINE# #UNINDENT# oauth_callback_confirmed = ( request_tokens . get ( 'oauth_callback_confirmed' ) == 'true' ) #NEWLINE# auth_url_params = { #NEWLINE# #INDENT# 'oauth_token' : request_tokens [ 'oauth_token' ] , #NEWLINE# #UNINDENT# } #NEWLINE# if force_login : #NEWLINE# #INDENT# auth_url_params . update ( { #NEWLINE# #INDENT# 'force_login' : force_login , #NEWLINE# 'screen_name' : screen_name , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# if ( callback_url and ( not oauth_callback_confirmed ) ) : #NEWLINE# #INDENT# auth_url_params [ 'oauth_callback' ] = self . callback_url #NEWLINE# #UNINDENT# request_tokens [ 'auth_url' ] = ( ( self . authenticate_url + '?' ) + urlencode ( auth_url_params ) ) #NEWLINE# return request_tokens