Skip to content

Instantly share code, notes, and snippets.

@Lawrence-Liu
Created September 12, 2015 02:53
Show Gist options
  • Save Lawrence-Liu/54184dc00b0e148638a8 to your computer and use it in GitHub Desktop.
Save Lawrence-Liu/54184dc00b0e148638a8 to your computer and use it in GitHub Desktop.
an example of getting access credentials for a user
import tweepy
#load consumer credentials
with open('/Users/lawrence/Documents/twitter_bot/keys.pass', 'r') as keys:
CONSUMER_KEY = keys.readline().split(':')[1].strip('\n')
CONSUMER_SECRET = keys.readline().split(':')[1].strip('\n')
#create an OAuth handler
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
#get redirected url
try:
redirect_url = auth.get_authorization_url()
except tweepy.TweepError:
print 'Error! Failed to get request token.'
#go to redirected_url
print redirect_url
#get the PIN and pass it to following method
auth.get_access_token('3053245')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment