postaddictme / instagram-php-scraper

Get account information, photos, videos, stories and comments.
https://packagist.org/packages/raiym/instagram-php-scraper
MIT License
3.1k stars 800 forks source link

User credentials are wrong / Client error: `/accounts/login/ajax/` resulted in a `400 Bad Request` response: {"message":"checkpoint_required","checkpoint_url":"/challenge/action/(...)"} #1089

Open iammati opened 2 years ago

iammati commented 2 years ago

Hello, I'm experiencing the following error currently in production:

Client error: POST https://www.instagram.com/accounts/login/ajax/ resulted in a 400 Bad Request response: {"message":"checkpoint_required","checkpoint_url":"/challenge/action/[...] (truncated...)

It also throws the "User credentials are wrong." exception within the InstagramAuthException class. The credentials are working fine when I login on instagram.com...

Using v0.11.2 of this package with PHP v7.4.30

This is my code:

$instagram = Instagram::withCredentials(
            new Client(),
            getenv('INSTAGRAM_USERNAME'),
            getenv('INSTAGRAM_PASSWORD'),
            new Psr16Adapter(
                'Files',
                new ConfigurationOption([
                    'defaultTtl' => 43200, // 12 hours
                ])
            )
        );

        try {
            $instagram->login(true);
            $instagram->saveSession();
            self::$instagram = $instagram;
        } catch (InstagramAuthException $e) {
            throw $e;
            // echo '<!-- <p style="display: none;">InstagramAuthException catched</p> -->';
        }

        dd('done');
jailrobeta commented 2 years ago

same problem here

jailrobeta commented 2 years ago

solved with change ip, or use proxy

wailashraf71 commented 2 years ago

Changing IP by using proxy shows unusual login attempt ❌

DanielB1990 commented 2 years ago

solved with change ip, or use proxy

@jailrobeta could you explain how, and with what you've set-up a proxy?

thatcoolguy commented 2 years ago

Is anybody able to bypass this? I even tried proxies but cannot bypass it.

DanielB1990 commented 2 years ago

Currently trying to.

I've set-up a squid proxy at home on a raspberry pi with docker and will report back if it's successful.

thatcoolguy commented 2 years ago

Currently trying to.

I've set-up a squid proxy at home on a raspberry pi with docker and will report back if it's successful.

We did not hear back from you?

DanielB1990 commented 2 years ago

@thatcoolguy so far so good.

What I've done:

  1. Set-up ZeroTier VPN and connect server and raspberry pi to same network, can also be done with WireGuard or any other VPN network provider.
  2. Set-up squid proxy server based on my own dockerfile combined from information found on the internet.
  3. Made changes to the script to proxy through squid on raspberry pi

So far it all works as expected, though as I want to make sure I stay under the radar of 'abusive' usage and my account being disabled, I've also made changes to:

So that part is a bit more out of scope, I'll share my docker-compose & dockerfile, and a anonymized php script later on, I'm on mobile now.

DanielB1990 commented 2 years ago

I've created DanielB1990/instagram-php-scraper-squid-proxy to share my docker-compose, dockerfile and php example, feel free to use and improve.