Skip to content

Instantly share code, notes, and snippets.

@svmotha
Last active June 11, 2017 03:39

Revisions

  1. svmotha revised this gist Jun 11, 2017. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions authentication.py
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    import tweepy
    from keyStorage.keys import keys

    class apiConnect():
    def __init__(self, **kwargs):
    self.__dict__.update(kwargs)
  2. svmotha created this gist Jun 11, 2017.
    22 changes: 22 additions & 0 deletions authentication.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    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