notmarek / BeFake

BeReal Python API wrapper
131 stars 29 forks source link

Error on login: `'BeFake' object has no attribute 'refresh_token'` #97

Closed NicoWeio closed 1 year ago

NicoWeio commented 1 year ago

I haven't dived super deep into the code, but it seems like we don't even try to set self.refresh_token anywhere. The API responses seem to indicate success. Maybe this is a regression from one of the latest commits? Does login currently work for anyone?

$ ./befake.py login <+4900000000000>
Enter otp: <000000>
Traceback (most recent call last):
  File "/home/nicolai/Daten/Programmieren/_Forks/BeFake/./befake.py", line 6, in <module>
    cli(obj={})
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/nicolai/Daten/Programmieren/_Forks/BeFake/BeFake/__main__.py", line 55, in login
    bf.verify_otp_vonage(otp)
  File "/home/nicolai/Daten/Programmieren/_Forks/BeFake/BeFake/BeFake.py", line 240, in verify_otp_vonage
    self.firebase_refresh_tokens()
  File "/home/nicolai/Daten/Programmieren/_Forks/BeFake/BeFake/BeFake.py", line 294, in firebase_refresh_tokens
    self.save()
  File "/home/nicolai/Daten/Programmieren/_Forks/BeFake/BeFake/BeFake.py", line 76, in save
    session = {"access": {"refresh_token": self.refresh_token,
AttributeError: 'BeFake' object has no attribute 'refresh_token'. Did you mean: 'refresh_tokens'?
K4CZP3R commented 1 year ago

Same here, quick fix is to update save() function:

    def get_session(self):
        session = {"access": {}, "firebase": {}}

        if hasattr(self, "refresh_token"):
            session["access"]["refresh_token"] = self.refresh_token
        if hasattr(self, "token"):
            session["access"]["token"] = self.token
        if hasattr(self, "expiration"):
            session["access"]["expires"] = self.expiration.timestamp()
        if hasattr(self, "firebase_refresh_token"):
            session["firebase"]["refresh_token"] = self.firebase_refresh_token
        if hasattr(self, "firebase_token"):
            session["firebase"]["token"] = self.firebase_token
        if hasattr(self, "firebase_expiration"):
            session["firebase"]["expires"] = self.firebase_expiration.timestamp()
        if hasattr(self, "user_id"):
            session["user_id"] = self.user_id

        return session

    def save(self, file_path: Optional[str] = None) -> None:
        session = self.get_session()
        ...
omtoi101 commented 1 year ago

Same here, quick fix is to update save() function:

    def get_session(self):
        session = {"access": {}, "firebase": {}}

        if hasattr(self, "refresh_token"):
            session["access"]["refresh_token"] = self.refresh_token
        if hasattr(self, "token"):
            session["access"]["token"] = self.token
        if hasattr(self, "expiration"):
            session["access"]["expires"] = self.expiration.timestamp()
        if hasattr(self, "firebase_refresh_token"):
            session["firebase"]["refresh_token"] = self.firebase_refresh_token
        if hasattr(self, "firebase_token"):
            session["firebase"]["token"] = self.firebase_token
        if hasattr(self, "firebase_expiration"):
            session["firebase"]["expires"] = self.firebase_expiration.timestamp()
        if hasattr(self, "user_id"):
            session["user_id"] = self.user_id

        return session

    def save(self, file_path: Optional[str] = None) -> None:
        session = self.get_session()
        ...

Throws a bad gateway error further along File "/usr/local/lib/python3.9/dist-packages/BeFake/BeFake.py", line 287, in grant_access_token raise Exception(res.content) Exception: b'<html>\r\n<head><title>502 Bad Gateway</title></head>\r\n<body>\r\n<center><h1>502 Bad Gateway</h1></center>\r\n<hr><center>nginx</center>\r\n</body>\r\n</html>\r\n'

NicoWeio commented 1 year ago

@omtoi101 Sounds like retrying might help in that case.

omtoi101 commented 1 year ago

@NicoWeio yeah haha retried a few times and same result, left it for an hour and it starts working 🤷‍♂️

ldoench commented 1 year ago

I already tried it for 3 day, but still have the same problem:

Traceback (most recent call last):
  File "/opt/homebrew/bin/befake", line 8, in <module>
    sys.exit(cli())
  File "/opt/homebrew/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/opt/homebrew/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/opt/homebrew/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/homebrew/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/homebrew/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/opt/homebrew/lib/python3.9/site-packages/BeFake/__main__.py", line 55, in login
    bf.verify_otp_vonage(otp)
  File "/opt/homebrew/lib/python3.9/site-packages/BeFake/BeFake.py", line 240, in verify_otp_vonage
    self.firebase_refresh_tokens()
  File "/opt/homebrew/lib/python3.9/site-packages/BeFake/BeFake.py", line 294, in firebase_refresh_tokens
    self.save()
  File "/opt/homebrew/lib/python3.9/site-packages/BeFake/BeFake.py", line 76, in save
    session = {"access": {"refresh_token": self.refresh_token,
AttributeError: 'BeFake' object has no attribute 'refresh_token'
omtoi101 commented 1 year ago

I already tried it for 3 day, but still have the same problem:


Traceback (most recent call last):

  File "/opt/homebrew/bin/befake", line 8, in <module>

    sys.exit(cli())

  File "/opt/homebrew/lib/python3.9/site-packages/click/core.py", line 1130, in __call__

    return self.main(*args, **kwargs)

  File "/opt/homebrew/lib/python3.9/site-packages/click/core.py", line 1055, in main

    rv = self.invoke(ctx)

  File "/opt/homebrew/lib/python3.9/site-packages/click/core.py", line 1657, in invoke

    return _process_result(sub_ctx.command.invoke(sub_ctx))

  File "/opt/homebrew/lib/python3.9/site-packages/click/core.py", line 1404, in invoke

    return ctx.invoke(self.callback, **ctx.params)

  File "/opt/homebrew/lib/python3.9/site-packages/click/core.py", line 760, in invoke

    return __callback(*args, **kwargs)

  File "/opt/homebrew/lib/python3.9/site-packages/BeFake/__main__.py", line 55, in login

    bf.verify_otp_vonage(otp)

  File "/opt/homebrew/lib/python3.9/site-packages/BeFake/BeFake.py", line 240, in verify_otp_vonage

    self.firebase_refresh_tokens()

  File "/opt/homebrew/lib/python3.9/site-packages/BeFake/BeFake.py", line 294, in firebase_refresh_tokens

    self.save()

  File "/opt/homebrew/lib/python3.9/site-packages/BeFake/BeFake.py", line 76, in save

    session = {"access": {"refresh_token": self.refresh_token,

AttributeError: 'BeFake' object has no attribute 'refresh_token'

@ldoench make sure you are on the latest version of the package please try pip install --upgrade git+https://github.com/notmarek/BeFake

sanderDijkxhoorn commented 1 year ago

Same issue here been like this for a while too have tried multiple methods but no success:


Enter otp: 620461
Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.9/dist-packages/BeFake/__main__.py", line 434, in <module>
    cli(obj={})
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/BeFake/__main__.py", line 55, in login
    bf.verify_otp_vonage(otp)
  File "/usr/local/lib/python3.9/dist-packages/BeFake/BeFake.py", line 240, in verify_otp_vonage
    self.firebase_refresh_tokens()
  File "/usr/local/lib/python3.9/dist-packages/BeFake/BeFake.py", line 294, in firebase_refresh_tokens
    self.save()
  File "/usr/local/lib/python3.9/dist-packages/BeFake/BeFake.py", line 76, in save
    session = {"access": {"refresh_token": self.refresh_token,
AttributeError: 'BeFake' object has no attribute 'refresh_token'
ldoench commented 1 year ago

@omtoi101

It already is:

Collecting git+https://github.com/notmarek/BeFake
  Cloning https://github.com/notmarek/BeFake to /private/var/folders/13/l8qy7cfd745_pg0c4rgt8dbm0000gp/T/pip-req-build-b9ksi5p5
  Running command git clone --filter=blob:none --quiet https://github.com/notmarek/BeFake /private/var/folders/13/l8qy7cfd745_pg0c4rgt8dbm0000gp/T/pip-req-build-b9ksi5p5
  Resolved https://github.com/notmarek/BeFake to commit ed612c7e5167e23716af792464edadb17267bdf8
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: click==8.1.3 in /opt/homebrew/lib/python3.9/site-packages (from BeFake==1.0.1) (8.1.3)
Requirement already satisfied: httpx==0.23.0 in /opt/homebrew/lib/python3.9/site-packages (from BeFake==1.0.1) (0.23.0)
Requirement already satisfied: pendulum==2.1.2 in /opt/homebrew/lib/python3.9/site-packages (from BeFake==1.0.1) (2.1.2)
Requirement already satisfied: pillow==9.2.0 in /opt/homebrew/lib/python3.9/site-packages (from BeFake==1.0.1) (9.2.0)
Requirement already satisfied: tzdata in /opt/homebrew/lib/python3.9/site-packages (from BeFake==1.0.1) (2023.3)
Requirement already satisfied: certifi in /opt/homebrew/lib/python3.9/site-packages (from httpx==0.23.0->BeFake==1.0.1) (2023.5.7)
Requirement already satisfied: sniffio in /opt/homebrew/lib/python3.9/site-packages (from httpx==0.23.0->BeFake==1.0.1) (1.3.0)
Requirement already satisfied: rfc3986[idna2008]<2,>=1.3 in /opt/homebrew/lib/python3.9/site-packages (from httpx==0.23.0->BeFake==1.0.1) (1.5.0)
Requirement already satisfied: httpcore<0.16.0,>=0.15.0 in /opt/homebrew/lib/python3.9/site-packages (from httpx==0.23.0->BeFake==1.0.1) (0.15.0)
Requirement already satisfied: python-dateutil<3.0,>=2.6 in /opt/homebrew/lib/python3.9/site-packages (from pendulum==2.1.2->BeFake==1.0.1) (2.8.2)
Requirement already satisfied: pytzdata>=2020.1 in /opt/homebrew/lib/python3.9/site-packages (from pendulum==2.1.2->BeFake==1.0.1) (2020.1)
Requirement already satisfied: h11<0.13,>=0.11 in /opt/homebrew/lib/python3.9/site-packages (from httpcore<0.16.0,>=0.15.0->httpx==0.23.0->BeFake==1.0.1) (0.12.0)
Requirement already satisfied: anyio==3.* in /opt/homebrew/lib/python3.9/site-packages (from httpcore<0.16.0,>=0.15.0->httpx==0.23.0->BeFake==1.0.1) (3.6.2)
Requirement already satisfied: idna>=2.8 in /opt/homebrew/lib/python3.9/site-packages (from anyio==3.*->httpcore<0.16.0,>=0.15.0->httpx==0.23.0->BeFake==1.0.1) (3.4)
Requirement already satisfied: six>=1.5 in /opt/homebrew/lib/python3.9/site-packages (from python-dateutil<3.0,>=2.6->pendulum==2.1.2->BeFake==1.0.1) (1.16.0)

I also tried it on another machine and there I get the same problem.

ldoench commented 1 year ago

@notmarek Can you check, if you are still able to login? And if so what steps did you take, since I can't get it to work, no matter what I try.

ldoench commented 1 year ago

Today I got a different error. Controlled the OTP twice, that i did not mistype it. Maybe caused since I used 00 instead of + at the beginning of my phone number? In the log I replaced the OTP with X

Enter otp: XXXXXX
Error: 500Error
Make sure you entered the right code
Traceback (most recent call last):
  File "/opt/homebrew/bin/befake", line 8, in <module>
    sys.exit(cli())
  File "/opt/homebrew/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/opt/homebrew/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/opt/homebrew/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/homebrew/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/homebrew/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/opt/homebrew/lib/python3.9/site-packages/BeFake/__main__.py", line 55, in login
    bf.verify_otp_vonage(otp)
  File "/opt/homebrew/lib/python3.9/site-packages/BeFake/BeFake.py", line 231, in verify_otp_vonage
    "token": vonageRes["token"],
KeyError: 'token'
nicop2000 commented 1 year ago

I second the error messages above

ALutz273 commented 1 year ago

Today I got a different error. Controlled the OTP twice, that i did not mistype it. Maybe caused since I used 00 instead of + at the beginning of my phone number? In the log I replaced the OTP with X

Enter otp: XXXXXX
Error: 500Error
Make sure you entered the right code
Traceback (most recent call last):
  File "/opt/homebrew/bin/befake", line 8, in <module>
    sys.exit(cli())
  File "/opt/homebrew/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/opt/homebrew/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/opt/homebrew/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/homebrew/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/homebrew/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/opt/homebrew/lib/python3.9/site-packages/BeFake/__main__.py", line 55, in login
    bf.verify_otp_vonage(otp)
  File "/opt/homebrew/lib/python3.9/site-packages/BeFake/BeFake.py", line 231, in verify_otp_vonage
    "token": vonageRes["token"],
KeyError: 'token'

have exactly the same error message.

[ansible@befake BeFake]$ python3 --version Python 3.9.16 [ansible@befake BeFake]$ cat /etc/os-release NAME="AlmaLinux" VERSION="9.2 (Turquoise Kodkod)" ID="almalinux" ID_LIKE="rhel centos fedora" VERSION_ID="9.2"