pgrimaud / instagram-user-feed

This is a scrapper to easily fetch any feed and interact with Instagram (like, follow, etc.) without OAuth for PHP.
MIT License
873 stars 136 forks source link

Can't login to Instagram properly #123

Closed eldark closed 3 years ago

eldark commented 4 years ago

Version(s) affected: 6.3 6.7

Description
I can't seem to be able to login to Instagram properly under Lubuntu 18.04. This is a brand new Instagram account I opened from my device. It silentlly fails (I've set error_reporting(E_ALL); and ini_set('display_errors', 1);). When I purposely put the wrong password as part of credentials, I get an InstagramAuthException. This account is associated to a Gmail account (imap.google.com:993), to which the confirmation mail never arrives. Tried manually installing, via apt, php-guzzlehttp-promises. Also tried with PHP 7.2, 7.3 and 7.4. Finally, if I copy the whole project as is to a Windows machine, it works flawlessly.

How to reproduce
I used the provided examples, modified to my credentials.

Possible Solution
No clue. It's a mistery.

Additional context
No IP blocking (I'm trying with a Windows machine, on the same LAN, and it works). No firewalls. DMZ'ed router.

eldark commented 4 years ago

Additionally, I want to address that I tried A LOT of things, most of which where related to php.ini, ssl certificates, etc, of which I honestly forgot most of the things.

pgrimaud commented 4 years ago

Hello @eldark

As discussed on Twitter, it's fucking weird... 😄 Is you Lubuntu 18.04 environment on your personal computer as OS ? Or on a Docker container? Or other stuff?

eldark commented 4 years ago

Hi there, Pierre. It's an old MSI Atom netbook, which I re-purposed as a tiny server. No virtualization of any kind involved. It is connected directly to the router, with no restrictions whatsoever. It would be super useful if anyone could replicate the problem. I will try this same setup in a virtual machine. Will update.

pgrimaud commented 4 years ago

Could you clone this projet on your MSI netbook ? Not as dependency but directly this github repository, then run composer install and vendor/bin/phpunit.

eldark commented 4 years ago

Certainly!

Log of bash:

~/tests/instagram-user-feed$ composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 59 installs, 0 updates, 0 removals
  - Installing symfony/polyfill-ctype (v1.18.1): Downloading (100%)
  - Installing symfony/deprecation-contracts (v2.1.3): Downloading (100%)
  - Installing symfony/yaml (v5.1.5): Downloading (100%)
  - Installing psr/container (1.0.0): Downloading (100%)
  - Installing symfony/service-contracts (v2.1.3): Downloading (100%)
  - Installing psr/cache (1.0.1): Downloading (100%)
  - Installing symfony/stopwatch (v5.1.5): Downloading (100%)
  - Installing symfony/polyfill-php80 (v1.18.1): Loading from cache
  - Installing symfony/polyfill-mbstring (v1.18.1): Downloading (100%)
  - Installing symfony/polyfill-intl-normalizer (v1.18.1): Downloading (100%)
  - Installing symfony/polyfill-intl-grapheme (v1.18.1): Downloading (100%)
  - Installing symfony/string (v5.1.5): Downloading (100%)
  - Installing symfony/polyfill-php73 (v1.18.1): Downloading (100%)
  - Installing symfony/console (v5.1.5): Downloading (100%)
  - Installing psr/log (1.1.3): Downloading (100%)
  - Installing symfony/filesystem (v5.1.5): Downloading (100%)
  - Installing symfony/config (v5.1.5): Downloading (100%)
  - Installing ralouphie/getallheaders (3.0.3): Downloading (100%)
  - Installing psr/http-message (1.0.1): Downloading (100%)
  - Installing guzzlehttp/psr7 (1.6.1): Downloading (100%)
  - Installing guzzlehttp/promises (v1.3.1): Downloading (100%)
  - Installing symfony/polyfill-php72 (v1.18.1): Downloading (100%)
  - Installing paragonie/random_compat (v9.99.99): Downloading (100%)
  - Installing symfony/polyfill-php70 (v1.18.1): Downloading (100%)
  - Installing symfony/polyfill-intl-idn (v1.18.1): Downloading (100%)
  - Installing guzzlehttp/guzzle (6.5.5): Downloading (100%)
  - Installing php-coveralls/php-coveralls (v2.2.0): Downloading (100%)
  - Installing symfony/var-exporter (v5.1.5): Loading from cache
  - Installing symfony/cache-contracts (v2.1.3): Downloading (100%)
  - Installing symfony/cache (v5.1.5): Downloading (100%)
  - Installing sebastian/version (2.0.1): Downloading (100%)
  - Installing sebastian/type (1.1.3): Downloading (100%)
  - Installing sebastian/resource-operations (2.0.1): Downloading (100%)
  - Installing sebastian/recursion-context (3.0.0): Downloading (100%)
  - Installing sebastian/object-reflector (1.1.1): Downloading (100%)
  - Installing sebastian/object-enumerator (3.0.3): Downloading (100%)
  - Installing sebastian/global-state (3.0.0): Downloading (100%)
  - Installing sebastian/exporter (3.1.2): Downloading (100%)
  - Installing sebastian/environment (4.2.3): Downloading (100%)
  - Installing sebastian/diff (3.0.2): Downloading (100%)
  - Installing sebastian/comparator (3.0.2): Downloading (100%)
  - Installing phpunit/php-timer (2.1.2): Downloading (100%)
  - Installing phpunit/php-text-template (1.2.1): Downloading (100%)
  - Installing phpunit/php-file-iterator (2.0.2): Downloading (100%)
  - Installing theseer/tokenizer (1.2.0): Downloading (100%)
  - Installing sebastian/code-unit-reverse-lookup (1.0.1): Downloading (100%)
  - Installing phpunit/php-token-stream (3.1.1): Downloading (100%)
  - Installing phpunit/php-code-coverage (7.0.10): Downloading (100%)
  - Installing doctrine/instantiator (1.3.1): Downloading (100%)
  - Installing phpdocumentor/reflection-common (2.2.0): Downloading (100%)
  - Installing webmozart/assert (1.9.1): Downloading (100%)
  - Installing phpdocumentor/type-resolver (1.3.0): Downloading (100%)
  - Installing phpdocumentor/reflection-docblock (5.2.1): Downloading (100%)
  - Installing phpspec/prophecy (1.11.1): Downloading (100%)
  - Installing phar-io/version (2.0.1): Downloading (100%)
  - Installing phar-io/manifest (1.0.3): Downloading (100%)
  - Installing myclabs/deep-copy (1.10.1): Downloading (100%)
  - Installing phpunit/phpunit (8.5.8): Downloading (100%)
  - Installing symfony/var-dumper (v5.1.5): Downloading (100%)
symfony/service-contracts suggests installing symfony/service-implementation ()
symfony/polyfill-intl-normalizer suggests installing ext-intl (For best performance)
symfony/polyfill-intl-grapheme suggests installing ext-intl (For best performance)
symfony/console suggests installing symfony/event-dispatcher ()
symfony/console suggests installing symfony/lock ()
symfony/console suggests installing symfony/process ()
guzzlehttp/psr7 suggests installing zendframework/zend-httphandlerrunner (Emit PSR-7 responses)
paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.)
symfony/polyfill-intl-idn suggests installing ext-intl (For best performance)
php-coveralls/php-coveralls suggests installing symfony/http-kernel (Allows Symfony integration)
sebastian/global-state suggests installing ext-uopz (*)
phpunit/php-code-coverage suggests installing ext-xdebug (^2.7.2)
phpunit/phpunit suggests installing phpunit/php-invoker (^2.0.0)
phpunit/phpunit suggests installing ext-soap (*)
phpunit/phpunit suggests installing ext-xdebug (*)
symfony/var-dumper suggests installing ext-intl (To show region name in time zone dump)
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Writing lock file
Generating autoload files

EDIT: Formatting

eldark commented 3 years ago

Ok, new info. I edited the title accordingly.

I replicated my environment. Same machine, but Win10/32. It started working properly, but then it began "not finding" usernames. (Username not found Exception). Eventually, every single Username is not found at all.

Same IP where the environment is running on another machine, without problems.

Besides all the suggested things, I tried deleting everything in the cache folders, without results.

I'm up to trying other suggestions.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

eldark commented 3 years ago

Hi, Pierre! I'm reopening this as I re-created my environment in an Ubuntu Server (no-GUI), and I have some spare time to pinpoint what the problem might be.

I did unit testing on all the Auth tests, and they passed with no issue::

./vendor/bin/phpunit tests/Auth/LoginTest.php
OK (6 tests, 6 assertions)
./vendor/bin/phpunit tests/Auth/SessionTest.php
OK (1 test, 1 assertion)
./vendor/bin/phpunit tests/Auth/Checkpoint/ImapClientTest.php
OK (1 test, 4 assertions)
./vendor/bin/phpunit tests/Auth/Checkpoint/ChallengeTest.php
OK (2 tests, 2 assertions)

Another thing, if I change the Instagram password on my credentials.php file, I get the "wrong password" error, so it definitely tries to login.

Finally, I enabled Less secure app access from my Google Account: https://myaccount.google.com/security

Is there any way of logging every step the auth part takes, so as to pinpoint where is it failing?

EDIT: also updated affected version

EDIT 2: Changed the IMAP login values in credentials.php, and I get an IMAP error. So it DOES connect to the IMAP server. The problem is between Instagram sending the Checkpoint and the verification via IMAP.

eldark commented 3 years ago

This might be an issue purely related to my Operating System, as I tried it in my hosting provider (DreamHost, which uses Ubuntu) and it works properly.

EDIT: Inside an Ubuntu Server 20.04 x64, running as a VM, it works flawlessly. Will try with a live one and report back.

eldark commented 3 years ago

Ok, I tried with a live Ubuntu Server 20.04, and everything works properly. There must be some incompatibility in a package from versions prior to that one (I also tried upgrading my 16.04 to 18.04, with no change).

My specific issue has been properly fixed, but it's still a mistery.

Thanks a bunch!