mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-25 04:02:32 +01:00
[twitter] implement 'csrf' option (#2676)
This commit is contained in:
parent
08db8435f1
commit
9c8d895d19
@ -2271,6 +2271,19 @@ Description
|
||||
<https://help.twitter.com/en/using-twitter/twitter-conversations>`__.
|
||||
|
||||
|
||||
extractor.twitter.csrf
|
||||
----------------------
|
||||
Type
|
||||
``string``
|
||||
Default
|
||||
``"cookies"``
|
||||
Description
|
||||
Controls how to handle Cross Site Request Forgery (CSRF) tokens.
|
||||
|
||||
* ``"auto"``: Always auto-generate a token.
|
||||
* ``"cookies"``: Use token given by the ``ct0`` cookie if present.
|
||||
|
||||
|
||||
extractor.twitter.size
|
||||
----------------------
|
||||
Type
|
||||
|
@ -873,8 +873,11 @@ class TwitterAPI():
|
||||
cookies = extractor.session.cookies
|
||||
cookiedomain = extractor.cookiedomain
|
||||
|
||||
# CSRF
|
||||
csrf_token = cookies.get("ct0", domain=cookiedomain)
|
||||
csrf = extractor.config("csrf")
|
||||
if csrf is None or csrf == "cookies":
|
||||
csrf_token = cookies.get("ct0", domain=cookiedomain)
|
||||
else:
|
||||
csrf_token = None
|
||||
if not csrf_token:
|
||||
csrf_token = util.generate_token()
|
||||
cookies.set("ct0", csrf_token, domain=cookiedomain)
|
||||
|
Loading…
Reference in New Issue
Block a user