tweepy Not Authorized - tweepy.error.TweepError: Not authorized

Pratik Poddar picture Pratik Poddar · Oct 23, 2013 · Viewed 8.6k times · Source

I get the following error when I try to use tweepy for twitter authentication.

  File "/usr/local/lib/python2.7/dist-packages/tweepy/models.py", line 146, in followers
    return self._api.followers(user_id=self.id, **kargs)
  File "/usr/local/lib/python2.7/dist-packages/tweepy/binder.py", line 197, in _call
    return method.execute()
  File "/usr/local/lib/python2.7/dist-packages/tweepy/binder.py", line 173, in execute
    raise TweepError(error_msg, resp)
tweepy.error.TweepError: Not authorized.

I am not building a web app. So, authentication is simpler.

consumer_key="----------"
consumer_secret="----------"
access_token="--------------"
access_token_secret="-----------------"

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth)

api.get_user('---').followers()

Answer

Pratik Poddar picture Pratik Poddar · Oct 24, 2013

Fixed. The particular user had protected tweets. Hence, .followers() was failing.