Twitter-API-v2-sample-code icon indicating copy to clipboard operation
Twitter-API-v2-sample-code copied to clipboard

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

Open M-Ather opened this issue 4 years ago • 10 comments

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.

M-Ather avatar Dec 13 '21 10:12 M-Ather

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

andypiper avatar Dec 16 '21 14:12 andypiper

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.

arb-man-zk avatar Jan 08 '22 23:01 arb-man-zk

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.

ikemHood avatar Sep 12 '22 05:09 ikemHood

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" }

AkaiSedo avatar Oct 14 '22 16:10 AkaiSedo

  • Is the app part of a project with v2 access?
  • What level of access do you have to the API (this should work fine with Essential Access but just want to check)

andypiper avatar Oct 14 '22 16:10 andypiper

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!

AkaiSedo avatar Oct 15 '22 14:10 AkaiSedo

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

opostavnicha avatar Jan 05 '23 20:01 opostavnicha

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

serdarzuli avatar Mar 11 '23 12:03 serdarzuli

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

vardhans07 avatar Apr 21 '23 14:04 vardhans07