-
Notifications
You must be signed in to change notification settings - Fork 3
/
connect.py
29 lines (22 loc) · 827 Bytes
/
connect.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
26
27
28
29
import tweepy
from db_mongo import Database
import os
db_name = os.environ.get("DB_MOCKTHISTWEET")
db = Database()
db.connect_db(db_name)
db.select_col('environment')
consumer_key = db.find_object('consumer_key')
consumer_secret = db.find_object('consumer_secret')
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
print('Please visit: ' + auth.get_authorization_url())
oauth_token = auth.request_token['oauth_token']
oauth_token_secret = auth.request_token['oauth_token_secret']
auth.request_token['oauth_token'] = oauth_token
auth.request_token['oauth_token_secret'] = oauth_token_secret
verifier = input('Verifier code: ')
try:
a = auth.get_access_token(verifier)
db.find_and_modify('access_token', a[0])
db.find_and_modify('access_token_secret', a[1])
except tweepy.TweepError as e:
print(e)