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

constant 'BadAuthentication' #162

Open
therealchjones opened this issue May 27, 2022 · 20 comments
Open

constant 'BadAuthentication' #162

therealchjones opened this issue May 27, 2022 · 20 comments

Comments

@therealchjones
Copy link

Like others, I was using gpapi (and some higher-level tools) quite successfully until a few weeks ago, when I was hit by #159. However, in attempting to test #161, I'm now finding that instead I'm getting only 'Error=BadAuthentication' at every login attempt, both with the current codebase, the current PyPi package, and the PR code. Additionally, this seems to occur with accounts that were previously working as well as new accounts, happens whether or not the accounts have been used in an emulator to access the Play Store and accept terms and conditions, happens on different operating systems (current macOS and old Ubuntu 16.04, both with python 3.9) with different IPs. Any ideas?

@marty0678
Copy link

Getting the same issue as you, just simply Bad Authentication (even tried with app passwords).

@kallix
Copy link

kallix commented May 28, 2022

For me, the Bad Authentication error is solved by Installing requests==2.23.0

@marty0678
Copy link

@kallix which version of python are you on? In order to run requests 2.23.0 I need to downgrade to urllib3==1.25.11 but then that crashes with AttributeError: module 'urllib3.util.ssl_' has no attribute 'OP_NO_TICKET', which is fixed in 1.26.x. I am currently on Python 3.10.

@kallix
Copy link

kallix commented May 28, 2022

I run only python3.8 and 3.9. Never tested with 3.10.

@kallix
Copy link

kallix commented May 28, 2022

@marty0678 are you trying to login with an email and pass (hence trying to register a fake device), or do you already have the gsfId and AuthToken already? (warning: I believe a gsfId / AuthToken couple has a one-month validity -- not more)

In my experience: Login with an email and password does require requests==2.23.0. However, login with gsfId and AuthToken works with any version of requests. (you can quickly login from a machine with py 3.9 and request==2.23.0, get the gsfId and authoken, and move those to your first machine.)

@marty0678
Copy link

On one Google account, the gsfId and AuthToken is still valid, so when I log in with that method it's working at the moment but like you said it'll expire so I can't count on it for much longer.

One new/existing accounts that the tokens have expired (or never received one), the email/password is what is failing. When I can get back to this in a few hours, I was planning on what you were suggesting, creating a venv with python 3.9 and requests 2.23 to try to get working as I'm currently running this API in a larger app that will be difficult to migrate back to python 3.9.

So if this works I will bundle up a Python 3.9 app separately and have the 3.10 app make calls to it. But first, need to confirm I can get it working with 3.9 and requests 2.23 as you said. Thanks for your help, I'll update this thread when I get back to this!

@ibdwbp
Copy link

ibdwbp commented May 28, 2022

Applied #161 on top of gentoolinux fix to Bad Authentication (gentoolinux@6e4c7a4).
Be aware to apply 161 inline with gentoolinux patch.
Works for me and is independent of requests version.

@marty0678
Copy link

marty0678 commented May 28, 2022

Thanks for the link to gentoolinux@6e4c7a4 but I already had that fix from last year.

I eventually got it to work by reverting urllib3 to 1.25.11 (or 1.25.10) then replacing the ssl_.OP_NO_TICKET with the default value from the newer SSL library that contains that missing option in 1.25.x.

You can see my PR in my fork and that specific change here:
marty0678@a64cb59#diff-8603cb7eaa65628bc3cc25edaf349cf45a979eebf3e380eff28b66f735575165R63

@therealchjones
Copy link
Author

Here's what I've been able to get to work, all thanks to @marty0678's fork marty0678/googleplay-api

git clone https://github.com/marty0678/googleplay-api
cd googleplay-api
python3 -m venv .venv
. .venv/bin/activate
pip3 install -r requirements.txt
pip3 install --upgrade protobuf
python3 setup.py build
pip3 install .
python3 test/obb_download_test.py -e <email> -p <password>

For what it's worth, this is Python 3.9.2 installed via Homebrew running on macOS Monterey 12.4, using a gmail account with 2FA and using an app password, having previously logged into the Play Store on an emulator and accepted all terms.

And again, thanks @marty0678!

@Christophe31
Copy link

Made it works with python 3.10, thx @marty0678

@adtimizer
Copy link

@marty0678 are you able to run your library on Linux? I would like run on AWS but failed to do so. when i tried on my mac (brew python 3.10) it works like magic.
Thanks BTW.

@marty0678
Copy link

@marty0678 are you able to run your library on Linux? I would like run on AWS but failed to do so. when i tried on my mac (brew python 3.10) it works like magic. Thanks BTW.

Haven't tried (I know one guy uses my app via WINE that incorporates this library, but that doesn't really count haha). AFAIK everything in this library is cross-compatible though, but I've only made some minor tweaks from the upstream and haven't really looked into the entire source code aside for what I've just done to get it to work.

@DavidRodriguezTorrado
Copy link

Hello there!
Thank you everyone for your answers.

I'm still stuck with this issue. I've tried installing a requests=2.23.0, the fork proposed by @marty0678, the @therealchjones proposal and also tried 2FA with app password configured in my Google account. I'm running Python 3.8.
Does anyone have any clue of what can be happening?

@mcozar99
Copy link

Hello there! Thank you everyone for your answers.

I'm still stuck with this issue. I've tried installing a requests=2.23.0, the fork proposed by @marty0678, the @therealchjones proposal and also tried 2FA with app password configured in my Google account. I'm running Python 3.8. Does anyone have any clue of what can be happening?

Hi David, same issue here with the same configuration, I do not know what is happening. Two days ago it was working perfectly

@martinwang2002
Copy link

I run gpapi on windows 11 and linux (ubuntu 22 with openssl 3).

With same version of python 3.10, gpapi==git+https://github.com/marty0678/googleplay-api, requests==2.23.0, urllib3==1.25.0, I can login on windows with email and app password, but received BadAuthentication on linux (ubuntu 22 with openssl 3).

Hope this helps.

@therealchjones
Copy link
Author

@mcozar99 & @DavidRodriguezTorrado, please try python 3.9; it doesn't seem to work with 3.8 (though I haven't looked into why).

@iamd0pey
Copy link

Here's what I've been able to get to work, all thanks to @marty0678's fork marty0678/googleplay-api

git clone https://github.com/marty0678/googleplay-api
cd googleplay-api
python3 -m venv .venv
. .venv/bin/activate
pip3 install -r requirements.txt
pip3 install --upgrade protobuf
python3 setup.py build
pip3 install .
python3 test/obb_download_test.py -e <email> -p <password>

For what it's worth, this is Python 3.9.2 installed via Homebrew running on macOS Monterey 12.4, using a gmail account with 2FA and using an app password, having previously logged into the Play Store on an emulator and accepted all terms.

And again, thanks @marty0678!

I have done everything but it keeps getting bad authentication, I'm using ubuntu 22.04 and I have tried with python 3.8, 3.9 and 3.10. I logged in first time too.

@marty0678
Copy link

Here's what I've been able to get to work, all thanks to @marty0678's fork marty0678/googleplay-api

git clone https://github.com/marty0678/googleplay-api
cd googleplay-api
python3 -m venv .venv
. .venv/bin/activate
pip3 install -r requirements.txt
pip3 install --upgrade protobuf
python3 setup.py build
pip3 install .
python3 test/obb_download_test.py -e <email> -p <password>

For what it's worth, this is Python 3.9.2 installed via Homebrew running on macOS Monterey 12.4, using a gmail account with 2FA and using an app password, having previously logged into the Play Store on an emulator and accepted all terms.
And again, thanks @marty0678!

I have done everything but it keeps getting bad authentication, I'm using ubuntu 22.04 and I have tried with python 3.8, 3.9 and 3.10. I logged in first time too.

I usually need to enable 2FA on the account, enable an app password to log in, and then sometimes (depending on how often I'm doing it) use a VPN for auth to finally work.

@iamd0pey
Copy link

iamd0pey commented Aug 26, 2022

Here's what I've been able to get to work, all thanks to @marty0678's fork marty0678/googleplay-api

git clone https://github.com/marty0678/googleplay-api
cd googleplay-api
python3 -m venv .venv
. .venv/bin/activate
pip3 install -r requirements.txt
pip3 install --upgrade protobuf
python3 setup.py build
pip3 install .
python3 test/obb_download_test.py -e <email> -p <password>

For what it's worth, this is Python 3.9.2 installed via Homebrew running on macOS Monterey 12.4, using a gmail account with 2FA and using an app password, having previously logged into the Play Store on an emulator and accepted all terms.
And again, thanks @marty0678!

I have done everything but it keeps getting bad authentication, I'm using ubuntu 22.04 and I have tried with python 3.8, 3.9 and 3.10. I logged in first time too.

I usually need to enable 2FA on the account, enable an app password to log in, and then sometimes (depending on how often I'm doing it) use a VPN for auth to finally work.

Use the app password as the password?

@GitHub30
Copy link

GitHub30 commented Sep 7, 2022

Here's what I've been able to get to work, all thanks to @marty0678's fork marty0678/googleplay-api

git clone https://github.com/marty0678/googleplay-api
cd googleplay-api
python3 -m venv .venv
. .venv/bin/activate
pip3 install -r requirements.txt
pip3 install --upgrade protobuf
python3 setup.py build
pip3 install .
python3 test/obb_download_test.py -e <email> -p <password>

For what it's worth, this is Python 3.9.2 installed via Homebrew running on macOS Monterey 12.4, using a gmail account with 2FA and using an app password, having previously logged into the Play Store on an emulator and accepted all terms.

And again, thanks @marty0678!

I am trying to run a script in Google Cloud Shell but I am getting this error: TypeError:"Descriptors cannot be installed directly"

Traceback (most recent call last):
  File "/home/gcpapk/googleplay-api/test/obb_download_test.py", line 1, in <module>
    from gpapi.googleplay import GooglePlayAPI
  File "/home/gcpapk/googleplay-api/.venv/lib/python3.9/site-packages/gpapi/googleplay.py", line 18, in <module>
    from . import googleplay_pb2, config, utils
  File "/home/gcpapk/googleplay-api/.venv/lib/python3.9/site-packages/gpapi/googleplay_pb2.py", line 36, in <module>
    _descriptor.FieldDescriptor(
  File "/home/gcpapk/googleplay-api/.venv/lib/python3.9/site-packages/google/protobuf/descriptor.py", line 560, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
 1. Downgrade the protobuf package to 3.20.x or lower.
 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates

It worked by downgrading.

git clone https://github.com/marty0678/googleplay-api
cd googleplay-api
python3 -m venv .venv
. .venv/bin/activate
pip3 install -r requirements.txt
pip3 install --upgrade protobuf==3.20.0
python3 setup.py build
pip3 install .
python3 test/obb_download_test.py -e <email> -p <password>

https://github.com/GitHub30/googleplay-api#download-apk

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