Skip to content

Instantly share code, notes, and snippets.

@cherdt
Created February 5, 2018 01:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cherdt/06f558f8f5edbe986deb13bd3cb013ca to your computer and use it in GitHub Desktop.
Save cherdt/06f558f8f5edbe986deb13bd3cb013ca to your computer and use it in GitHub Desktop.
get a twitter oauth token using the python birdy library
from birdy.twitter import UserClient
CONSUMER_KEY = 'getthisfromappstwittercom'
CONSUMER_SECRET = 'getthisfromappstwittercom'
client = UserClient(CONSUMER_KEY, CONSUMER_SECRET)
token = client.get_authorize_token()
ACCESS_TOKEN = token.oauth_token
ACCESS_TOKEN_SECRET = token.oauth_token_secret
print "Go to the following URL to get your PIN: "
print token.auth_url
# Get PIN (OAUTH_VERIFIER) from user
OAUTH_VERIFIER = raw_input("Enter PIN: ")
client = UserClient(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
token = client.get_access_token(OAUTH_VERIFIER)
# Display OAUTH token and secret
print "Save these values in your application: "
print "OAUTH_TOKEN = '" + token.oauth_token + "'"
print "OAUTH_TOKEN_SECRET = '" + token.oauth_token_secret + "'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment