Hi there, I’m having issues pulling user timeline for a user who has a private account (protected tweets) but we two follow each other. I can see all the tweets on the twitter webpage on his profile.
This is what I try:
Client.get_users_tweets(USER_ID, exclude=['replies'], max_results=5)
I’m using tweepy but I’m open to using just the requests library too. Also I get the same response in postman too. I could pull his tweets when it was not private, i asked him to make it private and now it results in an error response.
This is what the response is:
Response(data=None, includes={}, errors=[{'resource_id': '1349830532511764481', 'parameter': 'id', 'resource_type': 'user', 'section': 'data', 'title': 'Authorization Error', 'value': '1349830532511764481', 'detail': 'Sorry, you are not authorized to see the user with id: [1349830532511764481].', 'type': 'https://api.twitter.com/2/problems/not-authorized-for-resource'}], meta={})
it says I’m not authorized to see their tweets but I can see them on their profile…
what am I missing here?
Thank you for any help or suggestion : )
How are you authenticating calls - are you using Bearer token (App only) or Access tokens? (Consumer Keys & Access Tokens). It will not work with Bearer auth. The access token must belong to a user that’s allowed to follow the locked account.
@IgorBrigadir Thanks for the response : )
Yes I was using the Bearer Token. I switched to the oauth1.0a method and I’m able to pull data.
However the data returned contains a lotta info about tweets (fields), I only need the ID and text. How can I filter the tweets? I’m using tweepy but open to use any other lib or maybe even hitting the endpoints manually.
Also now that I’m using user auth, that means I have a limit of 900 requests per 15 minute right?
Yes, the limit is 900 calls in 15 minutes.
It maybe easier to simply ignore the fields you’re not interested in, or use expansions and fields: Using fields and expansions | Docs | Twitter Developer Platform in tweepy: Client — tweepy 4.10.1 documentation