revy
revy

Reputation: 4727

Twitter GET users/search client_credentials: Your credentials do not allow access to this resource

I have a static list of music artists and i want to get the id or screen_name of each one of them in Twitter.

I found this api endpoint: users/search which allows to run a query on Twitter and get all the accounts that match with the query. For example:

https://api.twitter.com/1.1/users/search.json?q=muse

will return all the accounts that match the query "muse". I need to call this endpoint in client_credentials flow, i don't need any permission by the user (which is only me in any case). The problem is that Twitter returns the following response when i try to access the endpoint in client_credentials flow:

"message": "Your credentials do not allow access to this resource", "code": 220

I have tested other API endpoints such users/show, statuses/retweets, statuses/user_timeline and they all works in client_credentials, just the one i need doesn't work. Is there anything i can do about that? Or i must change the OAUth flow?

Upvotes: 2

Views: 870

Answers (1)

Kevin
Kevin

Reputation: 931

mentioned error,

"{"errors":[{"message":"Your credentials do not allow access to this resource","code":220}]}"

comes when requesting an end point which requires a user context (such as statuses/home_timeline) using application only token.

You can verify whether or not same error comes for end points like statuses/home_timeline or statuses/retweets_of_me. These end points work only in some twitter user context. The end point that you want, users/search, also requires user context.

I am suspecting some issue in obtaining oauth token and secret. How are you getting authorized tokens for a given twitter user account?

Upvotes: 1

Related Questions