-
Notifications
You must be signed in to change notification settings - Fork 0
/
twitter.py
25 lines (19 loc) · 885 Bytes
/
twitter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from twython import Twython
from config import APP_KEY, APP_SECRET
def obtain_auth_url():
"""Used to app to tweet to my account
NOT CALLED ANYWHERE"""
twitter = Twython(APP_KEY, APP_SECRET)
auth = twitter.get_authentication_tokens()
oauth_token = auth['oauth_token']
oauth_token_secret = auth['oauth_token_secret']
print "\n\n\nGo to the following URL to authorize app:"
print auth['auth_url']
oauth_verifier = raw_input("\nEnter the pin: ")
twitter = Twython(APP_KEY, APP_SECRET, oauth_token, oauth_token_secret)
authorized = twitter.get_authorized_tokens(oauth_verifier)
#write confirmed tokens to disk
with open("config.py", "a") as config_file:
config_file.write("\n'OAUTH_TOKEN': '" + authorized['oauth_token']
+ "'\n'OAUTH_TOKEN_SECRET': '" + authorized['oauth_token_secret'] + "'")
obtain_auth_url()