skip to Main Content

I am trying to block a Twitter user using Python scripting and the Tweepy API. I am able to extract users, IDs, followers and tweets with no problem. When I try to call api.create_block(screen_name = '<some person I don't like>')
I get an exception
401 Unauthorized
(and that user is not blocked). I have been googling but only found old posts referring to my Windows time being not in sync. I synced the time and no improvement. I also tried blocking by ID but no luck.
Can anybody help ?

2

Answers


  1. Chosen as BEST ANSWER

    I am using OAuth 2.0 which does not allow separate read or write permissions. I tried with refreshed credentials but still the same. I did enable OAuth 1.0a and regenerated credentials (again) and now I can block users, Thanks !


  2. Make sure your app has the write permission.

    After giving it the write permission, make sure to regenerate and use new credentials to utilize it.

    https://tweepy.readthedocs.io/en/v4.8.0/faq.html#why-am-i-encountering-a-401-unauthorized-error-with-api-or-403-forbidden-error-with-client

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search