def oauth_dance(app_name, consumer_key, consumer_secret, token_filename=None):
    print("Hi there! We're gonna get you all set up to use %s." % app_name)
    auth = OAuth1Session(consumer_key, consumer_secret)
    access_token = auth.fetch_access_token('http://api.figshare.com/v1/pbl/oauth/request_token')

    print("""
In the web browser window that opens please choose to Allow
access. Copy the PIN number that appears on the next page and paste or
type it here:
""")
    oauth_url = auth.authorization_url('http://api.figshare.com/v1/pbl/oauth/authorize')

    try:
        assert 'DISPLAY' in os.environ
        r = webbrowser.open(oauth_url)
        time.sleep(2) # Sometimes the last command can print some
                      # crap. Wait a bit so it doesn't mess up the next
                      # prompt.
        if not r:
            raise Exception()
    except:
        print("""
Uh, I couldn't open a browser on your computer. Please go here to get
your PIN:

""" + oauth_url)
    oauth_verifier = _input("Please enter the PIN: ").strip()
    access_token = auth.fetch_access_token('http://api.figshare.com/v1/pbl/oauth/access_token?oauth_verifier=%s' % oauth_verifier)
    oauth_token = access_token['oauth_token']
    oauth_token_secret = access_token['oauth_token_secret']

    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
Generates a cookie signature.
dataset/ETHPy150Open rmcgibbo/figshare/figshare/oauth_dance.py/oauth_dance--crossover with--dataset/ETHPy150Open aino/python-fb/examples/oauth/facebookoauth.py/cookie_signature