labteral / pygram

Unofficial Python client for Instagram

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AuthenticationError when logging in with different Instagram Account

erikbrandondigital opened this issue · comments

Summary

I believe there is some kind of bug in the logic or order of execution for the _login function having to do with the cached login headers. When trying to log in to a different Instagram Account using the PyGram(username, password) call, I get an AuthenticationError. In addition, when copying my script between two different machines, I received the same AuthenticationError unless I also copied over the pygram-cache.json file too. I have checked and verified that my internet connection was working at the time so it likely isn't throwing any Error 500 or 400 codes which would throw the AuthenticationError.

Steps to reproduce the AuthenticationError:

(Requires 2 Instagram Accounts (A & B))

  1. Sign in to Instagram Account A by calling pygram = PyGram(username, password) as described in the ReadMe.md.

  2. Verify the pygram-cache.json file has been generated successfully.

  3. Sign in to Instagram Account B by calling pygram = PyGram(username, password) as described in the ReadMe.md.

  4. It throws the AuthenticationError and the pygram-cache.json file hasn't changed or updated because it failed to authenticate.

Below is the traceback from the error I received:

Traceback (most recent call last): File ".\getInstafollowers.py", line 67, in <module> pygram = PyGram(instaUserName, instaPassword) File "C:\Users\erikb\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\pygram\pygram.py", line 30, in __init__ self._login() File "C:\Users\erikb\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\pygram\pygram.py", line 137, in _login raise AuthenticationError pygram.errors.AuthenticationError

Hi @erik3165, thanks for the heads up. I'll try to take a look at this ASAP but I'm quite busy right now.

@brunneis No rush. Take your time. I just thought you should know.

@erik3165, I think it's fixed. Now multiple accounts can be cached (but the pygram-cache.json format has changed, you should delete the old one). There was a problem with the login (#3) so this problem should be fixed now. Feel free to reopen the issue if not.