xdevplatform / Twitter-API-v2-sample-code

Sample code for the Twitter API v2 endpoints
https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api
Apache License 2.0
2.66k stars 984 forks source link

Unauthorized Error 401. Tried to regenerate tokens but still issue persists #69

Open M-Ather opened 2 years ago

M-Ather commented 2 years ago

I am using python sample code provided in the repository. But I am getting "builtins.Exception: (401, '{\n "title": "Unauthorized",\n "type": "about:blank",\n "status": 401,\n "detail": "Unauthorized"\n}')" error whenever I try to fetch data using any Endpoint. I tried to regenerate tokens with Read, Write Permissions but still the issue persists.

andypiper commented 2 years ago

Have you set the correct environment variables? Which sample are you running?

arb-man-zk commented 2 years ago

Yes - to follow up. Same thing happening to me intermittently. Not sure if it is the control c exit not working properly in node.js, but once it quits on a timeout, it gives me a 401 error when i re open.

ikemHood commented 1 year ago

I do have same error. Making a recent searce with axios (Js) and header contains a bearer token which keeps responding Unauthorized. tried using it on Postman too with the same error. I have regenerated to no avail.

AkaiSedo commented 1 year ago

I am having the same problem running the sample code "Filtered-Stream" with either needle or axios with node.js. The environment variable is correct, I re-generated a bearer token, to no avail. Error: Unauthorized 401 Error: { "title": "Unauthorized", "type": "about:blank", "status": 401, "detail": "Unauthorized" }

andypiper commented 1 year ago
AkaiSedo commented 1 year ago

It is part of v2 access and so far I have Essential account. I managed to get it to work with needle (maybe temporary issue from twitter side?) but still get some error with axios. Not sure where the problem is but for now I have a working implementation so I will dig further!

opostavnicha commented 1 year ago

I keep getting the same error, both using Python and Postman..

serdarzuli commented 1 year ago

this case it's still open , omg why ? why nobody helps us ? i have same problem :/

vardhans07 commented 1 year ago

401 Traceback (most recent call last): File "c:\Users\dell\Desktop\try_1\tw_se_3.py", line 41, in main() File "c:\Users\dell\Desktop\try_1\tw_se_3.py", line 36, in main json_response = connect_to_endpoint(search_url, query_params) File "c:\Users\dell\Desktop\try_1\tw_se_3.py", line 31, in connect_to_endpoint raise Exception(response.status_code, response.text) Exception: (401, '{\n "title": "Unauthorized",\n "type": "about:blank",\n "status": 401,\n "detail": "Unauthorized"\n}')

[Done] exited with code=1 in 2.356 seconds

realHakeen commented 1 month ago

me 22222. Why no one helps us ...lol