mikf / gallery-dl

Command-line program to download image galleries and collections from several image hosting sites
GNU General Public License v2.0
10.66k stars 880 forks source link

1.27.0 [twitter][debug] API error: 'Could not authenticate you' #5733

Open Newbie1706 opened 1 week ago

Newbie1706 commented 1 week ago

Hi,

I am getting [twitter][debug] API error: 'Could not authenticate you' on tweets in v1.27.0.

It asks for a verification code that is emailed to me, which does not always happen very timeously. This happens after AccountDuplicationCheck, but the input is not shown in the logs. Then it continues with LoginAcid.

Do I have anything else that I need to set in my config or on Twitter itself?

[gallery-dl][debug] Version 1.27.0
[gallery-dl][debug] Python 3.10.6 - Windows-10-10.0.17763-SP0
[gallery-dl][debug] requests 2.32.3 - urllib3 2.2.1
[gallery-dl][debug] Configuration Files ['F:\\Applications\\Gallery DL\\gallery-dl-config-files.json']
[gallery-dl][debug] Starting DownloadJob for 'https://x.com/crazywheelz19/status/1800994118941790641'
[twitter][debug] Using TwitterTweetExtractor for 'https://x.com/crazywheelz19/status/1800994118941790641'
[twitter][debug] Loading cookies from 'F:/Applications/Gallery DL/Cookies/x.com_cookies.txt'
[urllib3.connectionpool][debug] Starting new HTTPS connection (1): x.com:443
[urllib3.connectionpool][debug] https://x.com:443 "GET /i/api/graphql/B9_KmbkLhXt6jRwGjJrweg/TweetDetail?variables=%7B%22focalTweetId%22%3A%221800994118941790641%22%2C%22referrer%22%3A%22profile%22%2C%22with_rux_injections%22%3Afalse%2C%22includePromotedContent%22%3Afalse%2C%22withCommunity%22%3Atrue%2C%22withQuickPromoteEligibilityTweetFields%22%3Atrue%2C%22withBirdwatchNotes%22%3Atrue%2C%22withVoice%22%3Atrue%2C%22withV2Timeline%22%3Atrue%7D&features=%7B%22responsive_web_graphql_exclude_directive_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Afalse%2C%22creator_subscriptions_tweet_preview_api_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22responsive_web_graphql_skip_user_profile_image_extensions_enabled%22%3Afalse%2C%22c9s_tweet_anatomy_moderator_badge_enabled%22%3Atrue%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Atrue%2C%22responsive_web_twitter_article_tweet_consumption_enabled%22%3Atrue%2C%22tweet_awards_web_tipping_enabled%22%3Afalse%2C%22freedom_of_speech_not_reach_fetch_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Atrue%2C%22rweb_video_timestamps_enabled%22%3Atrue%2C%22longform_notetweets_rich_text_read_enabled%22%3Atrue%2C%22longform_notetweets_inline_media_enabled%22%3Atrue%2C%22responsive_web_media_download_video_enabled%22%3Atrue%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D HTTP/1.1" 401 89
[twitter][debug] API error: 'Could not authenticate you'
[twitter][info] Requesting guest token
[urllib3.connectionpool][debug] Starting new HTTPS connection (1): api.x.com:443
[urllib3.connectionpool][debug] https://api.x.com:443 "POST /1.1/guest/activate.json HTTP/1.1" 200 63
[twitter][info] Logging in as newbie1707
[urllib3.connectionpool][debug] https://api.x.com:443 "POST /1.1/onboarding/task.json?flow_name=login HTTP/1.1" 200 245
[twitter][debug] Sleeping 2.81 seconds (login (LoginJsInstrumentationSubtask))
[urllib3.connectionpool][debug] https://api.x.com:443 "POST /1.1/onboarding/task.json HTTP/1.1" 200 971
[twitter][debug] Sleeping 2.50 seconds (login (LoginEnterUserIdentifierSSO))
[urllib3.connectionpool][debug] https://api.x.com:443 "POST /1.1/onboarding/task.json HTTP/1.1" 200 642
[twitter][debug] Sleeping 1.77 seconds (login (LoginEnterPassword))
[urllib3.connectionpool][debug] https://api.x.com:443 "POST /1.1/onboarding/task.json HTTP/1.1" 200 234
[twitter][debug] Sleeping 1.91 seconds (login (AccountDuplicationCheck))
[urllib3.connectionpool][debug] https://api.x.com:443 "POST /1.1/onboarding/task.json HTTP/1.1" 200 1014
[twitter][debug] Sleeping 1.48 seconds (login (LoginAcid))
[urllib3.connectionpool][debug] https://api.x.com:443 "POST /1.1/onboarding/task.json HTTP/1.1" 500 74
[twitter][debug] '500 Internal Server Error' for 'https://api.x.com/1.1/onboarding/task.json' (1/5)
[twitter][debug] Sleeping 1.00 seconds (retry)
[urllib3.connectionpool][debug] https://api.x.com:443 "POST /1.1/onboarding/task.json HTTP/1.1" 400 91
[twitter][debug] {"errors":[{"code":399,"message":"Incorrect. Please try again."}]}
[twitter][error] AuthenticationError: "Incorrect. Please try again."

Here is my config file (snipped the other extractors for brevity):

{
    "extractor": {
        "base-directory": "F:\\Data\\DL\\Files",
        "postprocessors": null,
        "archive": null,
        "cookies": null,
        "cookies-update": false,
        "proxy": null,
        "skip": true,
        "sleep": 0,
        "path-restrict": "auto",
        "path-remove": "\\u0000-\\u001f\\u007f",
        "user-agent": "Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0",
        "twitter": {
            "content": false,
            "retweets": true,
            "twitpic": true,
            "videos": true,
            "relogin": true,
            "cookies": "F:/Applications/Gallery DL/Cookies/x.com_cookies.txt",
            "username": "newbie1707",
            "password": "pretend we have the correct password here",
            "csrf": "auto",
            "postprocessors": [
                {
                    "name": "metadata",
                    "mode": "custom",
                    "extension": "txt",
                    "format": "{content}\n"
                }
            ]
        }
    },
    "downloader": {
        "part": true,
        "part-directory": null,
        "http": {
            "adjust-extensions": true,
            "mtime": true,
            "rate": null,
            "retries": 4,
            "timeout": 30.0,
            "verify": true
        },
        "ytdl": {
            "format": null,
            "forward-cookies": true,
            "mtime": true,
            "outtmpl": null,
            "rate": null,
            "retries": 4,
            "timeout": 30.0,
            "verify": true
        }
    },
    "output": {
        "mode": "auto",
        "progress": true,
        "shorten": true,
        "log": "[{name}][{levelname}] {message}",
        "logfile": null,
        "unsupportedfile": null
    },
    "cache": {
        "file": "/Cache/cacheFolders.sqlite3"
    },
    "netrc": false
}
Newbie1706 commented 1 week ago

The same link and configuration on 1.26.9 yields the following:

[gallery-dl][debug] Version 1.26.9
[gallery-dl][debug] Python 3.10.6 - Windows-10-10.0.17763-SP0
[gallery-dl][debug] requests 2.32.3 - urllib3 2.2.1
[gallery-dl][debug] Configuration Files ['F:\\Applications\\Gallery DL\\gallery-dl-config-files.json']
[gallery-dl][debug] Starting DownloadJob for 'https://x.com/crazywheelz19/status/1800994118941790641'
[twitter][debug] Using TwitterTweetExtractor for 'https://x.com/crazywheelz19/status/1800994118941790641'
[twitter][debug] Loading cookies from 'F:/Applications/Gallery DL/Cookies/x.com_cookies.txt'
[twitter][info] Requesting guest token
[urllib3.connectionpool][debug] Starting new HTTPS connection (1): api.twitter.com:443
[urllib3.connectionpool][debug] https://api.twitter.com:443 "POST /1.1/guest/activate.json HTTP/1.1" 200 63
[twitter][info] Logging in as newbie1707
[urllib3.connectionpool][debug] https://api.twitter.com:443 "POST /1.1/onboarding/task.json?flow_name=login HTTP/1.1" 200 247
[urllib3.connectionpool][debug] https://api.twitter.com:443 "POST /1.1/onboarding/task.json HTTP/1.1" 200 974
[twitter][debug] Sleeping 3.68 seconds (login (username))
[urllib3.connectionpool][debug] https://api.twitter.com:443 "POST /1.1/onboarding/task.json HTTP/1.1" 200 641
[twitter][debug] Sleeping 2.81 seconds (login (password))
[urllib3.connectionpool][debug] https://api.twitter.com:443 "POST /1.1/onboarding/task.json HTTP/1.1" 200 234
[urllib3.connectionpool][debug] https://api.twitter.com:443 "POST /1.1/onboarding/task.json HTTP/1.1" 200 1014
[urllib3.connectionpool][debug] Starting new HTTPS connection (1): twitter.com:443
[urllib3.connectionpool][debug] https://twitter.com:443 "GET /i/api/graphql/MWY3AO9_I3rcP_L2A4FR4A/TweetResultByRestId?variables=%7B%22tweetId%22%3A%221800994118941790641%22%2C%22withCommunity%22%3Afalse%2C%22includePromotedContent%22%3Afalse%2C%22withVoice%22%3Afalse%7D&features=%7B%22responsive_web_graphql_exclude_directive_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Afalse%2C%22creator_subscriptions_tweet_preview_api_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22responsive_web_graphql_skip_user_profile_image_extensions_enabled%22%3Afalse%2C%22c9s_tweet_anatomy_moderator_badge_enabled%22%3Atrue%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Atrue%2C%22responsive_web_twitter_article_tweet_consumption_enabled%22%3Atrue%2C%22tweet_awards_web_tipping_enabled%22%3Afalse%2C%22freedom_of_speech_not_reach_fetch_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Atrue%2C%22rweb_video_timestamps_enabled%22%3Atrue%2C%22longform_notetweets_rich_text_read_enabled%22%3Atrue%2C%22longform_notetweets_inline_media_enabled%22%3Atrue%2C%22responsive_web_media_download_video_enabled%22%3Atrue%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D HTTP/1.1" 200 105
[twitter][error] AuthorizationError: NSFW Tweet
thatfuckingbird commented 1 week ago

Also ran into this, I'm calling gallery-dl from another process, so when it got to the part where it's waiting for input it was just hanging indefinitely. Disabling relogin fixed this but I'd like if in the future, waiting for user input would get indicated in the logs so it's easy to see whats going on.

mikf commented 1 week ago

Well, either the value you entered during the LoginAcid step truly was incorrect as Twitter reports ("Incorrect. Please try again."), or something went wrong when retrying the 500 Internal Server Error request.

I have to admit that I've personally never tested these lines of code as I've never had to enter an email verification code when logging in. Much of this code is adopted from yt-dlp's login process and I assumed it would work.

The same link and configuration on 1.26.9 yields the following:

1.26.9 can only do a very simple login involving username & password and nothing else. In your case, it did an incomplete login and then proceeded as guest without reporting a login error.

@thatfuckingbird

I've added --no-input and input to allow disabling prompting for input. (https://github.com/mikf/gallery-dl/commit/a1bb32792b91e03c8440ff4fffdced4fe87f6e6f)

Newbie1706 commented 1 week ago

Well, either the value you entered during the LoginAcid step truly was incorrect as Twitter reports ("Incorrect. Please try again."), or something went wrong when retrying the 500 Internal Server Error request.

Yeah, I just entered something so that the log could finish. When I get the email that was triggered by the login and enter the code, it works. But many attempts in short succession do not get an email for each, so that also is a little problem (from Twitter's side, not yours 😅)

I am going to try creating a new account and see what it does. Maybe it flagged my account for whatever reason, even though I have been using this one for ages. I will let you know if anything significant comes up.

Newbie1706 commented 1 day ago

Okay, so finally I was able to resolve this. I use Psiphon, which is similar to a VPN. Long story short, I changed my location and then Twitter downloads resumed without any issue 😅