def oauth_dance(app_name, consumer_key, consumer_secret, token_filename=None, open_browser=True):
 print(("Hi there! We're gonna get you all set up to use %s." % app_name))
 twitter = Twitter(auth=OAuth('', '', consumer_key, consumer_secret), format='', api_version=None)
 (oauth_token, oauth_token_secret) = parse_oauth_tokens(twitter.oauth.request_token(oauth_callback='oob'))
 oauth_url = ('https://api.twitter.com/oauth/authorize?oauth_token=' + oauth_token)
 oauth_verifier = get_oauth_pin(oauth_url, open_browser)
 twitter = Twitter(auth=OAuth(oauth_token, oauth_token_secret, consumer_key, consumer_secret), format='', api_version=None)
 (oauth_token, oauth_token_secret) = parse_oauth_tokens(twitter.oauth.access_token(oauth_verifier=oauth_verifier))
 if token_filename:
  write_token_file(token_filename, oauth_token, oauth_token_secret)
  print()
  print(("That's it! Your authorization keys have been written to %s." % token_filename))
 return (oauth_token, oauth_token_secret)

def oauth_dance ( app_name , consumer_key , consumer_secret , token_filename = None , open_browser = True ) : print ( ( "Hi there! We're gonna get you all set up to use %s." % app_name ) ) twitter = Twitter ( auth = OAuth ( '' , '' , consumer_key , consumer_secret ) , format = '' , api_version = None ) ( oauth_token , oauth_token_secret ) = parse_oauth_tokens ( twitter . oauth . request_token ( oauth_callback = 'oob' ) ) oauth_url = ( 'https://api.twitter.com/oauth/authorize?oauth_token=' + oauth_token ) oauth_verifier = get_oauth_pin ( oauth_url , open_browser ) twitter = Twitter ( auth = OAuth ( oauth_token , oauth_token_secret , consumer_key , consumer_secret ) , format = '' , api_version = None ) ( oauth_token , oauth_token_secret ) = parse_oauth_tokens ( twitter . oauth . access_token ( oauth_verifier = oauth_verifier ) ) if token_filename : write_token_file ( token_filename , oauth_token , oauth_token_secret ) print ( ) print ( ( "That's it! Your authorization keys have been written to %s." % token_filename ) ) return ( oauth_token , oauth_token_secret )
perform the oauth dance with some command-line prompts .