From 9f5244485fbb7913ff504b5a150f5d2f5f1ed80b Mon Sep 17 00:00:00 2001 From: novenary Date: Tue, 9 May 2023 16:09:50 +0300 Subject: [PATCH] fix: Send CSRF token The search endpoint asks for it. --- twint/get.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/twint/get.py b/twint/get.py index bb0784e..ec61dde 100644 --- a/twint/get.py +++ b/twint/get.py @@ -109,12 +109,19 @@ def get_connector(config): async def RequestUrl(config, init): logme.debug(__name__ + ':RequestUrl') + csrf_token = random.randbytes(16).hex() # Looks like any random string works _connector = get_connector(config) _serialQuery = "" params = [] - cookies = {} + cookies = { + "ct0": csrf_token, + } _url = "" - _headers = [("authorization", config.Bearer_token), ("x-guest-token", config.Guest_token)] + _headers = { + "authorization": config.Bearer_token, + "x-guest-token": config.Guest_token, + "x-csrf-token": csrf_token, + } if config.Auth_token: cookies["auth_token"] = config.Auth_token