Created
September 12, 2015 02:53
-
-
Save Lawrence-Liu/54184dc00b0e148638a8 to your computer and use it in GitHub Desktop.
an example of getting access credentials for a user
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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