Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jl452 opened this issue Apr 6, 2022 · 4 comments

Comments

@jl452
Copy link

jl452 commented Apr 6, 2022

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 jl452 changed the title [instagram][proxy/vpn] 400 Bad Request after login try (but work in chromium with same proxy) [instagram][proxy/tor/vpn] 400 Bad Request after login try (but work in chromium with same proxy) Apr 6, 2022
@AlttiRi
Copy link

AlttiRi commented Apr 7, 2022

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.

@mikf
Copy link
Owner

mikf commented Apr 7, 2022

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.

@AlttiRi
Copy link

AlttiRi commented Apr 7, 2022

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)

@espressoelf
Copy link

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.

@mikf mikf closed this as completed Dec 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants