Last active
June 11, 2017 03:39
-
-
Save svmotha/ae8f3b8e09ca30f7f7571c50e6efb9c3 to your computer and use it in GitHub Desktop.
Tweepy twitter authentication with 'secret' twitter keys import.
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 | |
from keyStorage.keys import keys | |
class apiConnect(): | |
def __init__(self, **kwargs): | |
self.__dict__.update(kwargs) | |
# Authenticate user credentials and get access to twitter API | |
def authentication(self): | |
# Use user keys | |
CONSUMER_KEY = keys['consumer_key'] | |
CONSUMER_SECRET = keys['consumer_secret'] | |
ACCESS_KEY = keys['access_token'] | |
ACCESS_SECRET = keys['access_token_secret'] | |
# Authenticate twitter account credentials using tweepy | |
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) | |
# Set access keys for authenticated user | |
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET) | |
# Set twitter API through tweepy and return api | |
api = tweepy.API(auth, retry_count=5, | |
retry_errors=None, timeout=120, compression=False) | |
return api |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment