gallery-dl icon indicating copy to clipboard operation
gallery-dl copied to clipboard

[instagram][proxy/tor/vpn] 400 Bad Request after login try (but work in chromium with same proxy)

Open jl452 opened this issue 2 years ago • 4 comments

gallery-dl --proxy "127.0.0.1:8118" --get-url https://www.instagram.com/p/CaKUCI2gbJw/ -v

[gallery-dl][debug] Version 1.21.0 [gallery-dl][debug] Python 3.9.7 - Linux-5.16.12-051612-generic-x86_64-with-glibc2.34 [gallery-dl][debug] requests 2.25.1 - urllib3 1.26.5 [gallery-dl][debug] Starting UrlJob for 'https://www.instagram.com/p/CaKUCI2gbJw/' [instagram][debug] Using InstagramPostExtractor for 'https://www.instagram.com/p/CaKUCI2gbJw/' [urllib3.connectionpool][debug] Starting new HTTPS connection (1): www.instagram.com:443 [urllib3.connectionpool][debug] https://www.instagram.com:443 "GET /graphql/query/?query_hash=2efa04f61586458cef44441f474eee7c&variables=%7B%22shortcode%22%3A+%22CaKUCI2gbJw%22%2C+%22child_comment_count%22%3A+3%2C+%22fetch_comment_count%22%3A+40%2C+%22parent_comment_count%22%3A+24%2C+%22has_threaded_comments%22%3A+true%7D HTTP/1.1" 302 0 [urllib3.connectionpool][debug] https://www.instagram.com:443 "GET /accounts/login/?next=/graphql/query/ HTTP/1.1" 200 28050 [instagram][error] HTTP redirect to login page (https://www.instagram.com/accounts/login/?next=/graphql/query/)

gallery-dl -u user -p password --proxy "127.0.0.1:8118" --get-url https://www.instagram.com/p/CaKUCI2gbJw/ -v

[gallery-dl][debug] Version 1.21.0 [gallery-dl][debug] Python 3.9.7 - Linux-5.16.12-051612-generic-x86_64-with-glibc2.34 [gallery-dl][debug] requests 2.25.1 - urllib3 1.26.5 [gallery-dl][debug] Starting UrlJob for 'https://www.instagram.com/p/CaKUCI2gbJw/' [instagram][debug] Using InstagramPostExtractor for 'https://www.instagram.com/p/CaKUCI2gbJw/' [instagram][info] Logging in as user [urllib3.connectionpool][debug] Starting new HTTPS connection (1): www.instagram.com:443 [urllib3.connectionpool][debug] https://www.instagram.com:443 "GET /accounts/login/ HTTP/1.1" 200 28033 [instagram][debug] Sleeping for 11.11 seconds [urllib3.connectionpool][debug] https://www.instagram.com:443 "GET /data/shared_data/ HTTP/1.1" 200 16455 [instagram][debug] Sleeping for 6.451 seconds [urllib3.connectionpool][debug] https://www.instagram.com:443 "POST /accounts/login/ajax/ HTTP/1.1" 400 273 [instagram][error] HttpError: '400 Bad Request' for 'https://www.instagram.com/accounts/login/ajax/'

but in chromium with same tor's proxy (socks5) it success login and show post maybe i need use some data from chromium like cookies or useragent? ps: http-proxy create from socks5 by privoxy

jl452 avatar Apr 06 '22 12:04 jl452

Try to use all headers which the browser adds. Not only cookie and user-agent.

In particular sec-fetch-*, sec-ch-ua-*, upgrade-insecure-requests headers.

AlttiRi avatar Apr 07 '22 11:04 AlttiRi

socks5

You need to specify that in the proxy URL: --proxy socks5h://127.0.0.1:8118

maybe i need use some data from chromium like cookies or useragent?

You can export and use your browser cookies with gallery-dl: https://github.com/mikf/gallery-dl#cookies

sec-fetch-, sec-ch-ua-

~~Those are HTTP/2, which is not used in gallery-dl.~~ Logging in works with just the default headers.

mikf avatar Apr 07 '22 16:04 mikf

Those are HTTP/2

Not only, they are send to any https page independently is it http/1.1, or h2. ("Protocol" can be checked in DevTools, you need to enable the column by RMB in Network log table header)

(and localhost)

AlttiRi avatar Apr 07 '22 16:04 AlttiRi

I've had the same problem: gallery-dl could log-in but the API returned a 400 Bad Request for every link. I had to login via browser and provide my birthdate that Instagram requires for personalization now. It works again now. Use a throwaway account, provide false information.

espressoelf avatar Jul 02 '22 08:07 espressoelf