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

{'Error': 'BadAuthentication'} #24

Closed
alils opened this issue Mar 27, 2020 · 38 comments · Fixed by #25
Closed

{'Error': 'BadAuthentication'} #24

alils opened this issue Mar 27, 2020 · 38 comments · Fixed by #25

Comments

@alils
Copy link

alils commented Mar 27, 2020

I keep getting "{'Error': 'BadAuthentication'}" with either account password with 2factor authentication disabled and app password with 2fa enabled.

@simon-weber
Copy link
Owner

There's not much to go off of. Maybe there's some more information in the response? eg #23 (comment)

@alils
Copy link
Author

alils commented Mar 27, 2020

I've tried this with 2 accounts and I'm getting BadAuth every time. is there something specfic I need to do on my account to get this work?
First I tried with my account password with 2fa disabled, then I've enabled 2fa and have created app password. both times i'm getting {'Error': 'BadAuthentication'} when calling perform_master_login.
maybe it has something to do with android_id? what do I need to set as android_id when calling perform_master_login?

@simon-weber
Copy link
Owner

There's some details on what gmusicapi uses for device ids here. Ideally you'd reuse a real one that's already been attached to your account.

@alils
Copy link
Author

alils commented Mar 27, 2020

I'm using mac address of my laptop which is trusted by google in my account. However I still getting {'Error': 'BadAuthentication'}.

@simon-weber
Copy link
Owner

I'm not sure mac addresses work anymore. You might have to try a random android or ios id.

@alils
Copy link
Author

alils commented Mar 27, 2020

I've got android_id of my phone, same problem :( should this work without app password and 2fa disabled?

@simon-weber
Copy link
Owner

Yup, it worked for me earlier today.

@alils
Copy link
Author

alils commented Mar 27, 2020

is there anything else I have to do to get this work besides valid android_id and disabling 2fa ?

@simon-weber
Copy link
Owner

There shouldn't be. Did you try an ios id?

@alils
Copy link
Author

alils commented Mar 27, 2020

how can I get ios id from my iphone? I just tried with my boyfriend's account. it does not work either.

@simon-weber
Copy link
Owner

It's mentioned here: anything of the form ios:<uuid> is technically valid, eg ios:5f1fe11a-e296-4bb5-a214-cf9bc7f5c01b.

@alils
Copy link
Author

alils commented Mar 27, 2020

same with ios :(
here is the code that prints {'Error': 'BadAuthentication'}


from gpsoauth import perform_master_login

username = "email@gmail.com"
password = "passwd"
device_id = "device_id"
print(perform_master_login(username, password, device_id))



@alils
Copy link
Author

alils commented Mar 29, 2020

@simon-weber could you please look at the code? it does not work with 4 different accounts. I don't think it's something related to the account.

@simon-weber
Copy link
Owner

That code looks fine to me, and gpsoauth itself hasn't changed in a while. If there's no issues with the input or accounts, then it sounds like something changed on Google's end.

What are you trying to accomplish with gpsoauth? Will a normal oauth flow (even one that reuses another app's client credentials) work instead?

@alils
Copy link
Author

alils commented Mar 29, 2020

no, oauth won't help at this point because I'm trying to use google keep's unofficial API gkeeapi. I still can't understand why it's working with your accounts and not with mine :/

@simon-weber
Copy link
Owner

simon-weber commented Apr 19, 2020

[this was directed at another user that I think GitHub auto-blocked, since an earlier redacted comment is now gone:]

Can you share your solution here, please? I've edited out your contact information in the meantime, since I don't want to encourage people to reach out directly to someone unrelated to the project, especially when it may involve Google SSO credentials.

Repository owner deleted a comment Apr 19, 2020
Repository owner deleted a comment Apr 19, 2020
@alils
Copy link
Author

alils commented May 2, 2020

I did not see the comment, was there any solution?

@simon-weber
Copy link
Owner

No, I'm pretty sure they were some kind of scammer.

@HIT2022
Copy link

HIT2022 commented Aug 19, 2020

Did you figure this out @alils ? I'm running into the same issue.

@kkhanh
Copy link

kkhanh commented Oct 22, 2020

I'm running into the same problem. Tried different account and different combinations (2FA enable/disabled, plain text password, app password...)

@gabrielgunnarsson
Copy link

I also had this issue on Raspberry Pi running Python 3.5.3. For some reason, when I ran it on a Windows machine it worked. Both in Windows Subsystem for Linux and Windows. Python 3.8.5/3.8.6.

Upgraded the Pi to Python 3.9.0 but issue persists. Guess I'll just run it on Windows.

@chvancooten
Copy link

chvancooten commented Dec 20, 2020

Hey, I was experimenting with different Python versions (see here: rithvikvibhu/GHLocalApi#54) and for me it suddenly started working on Python 3.6.9 on Ubuntu Server. Both Python 3.7.5 and 3.8.6 did not work for me!

@simon-weber
Copy link
Owner

I haven't tested this, but I got an email from someone who claims downgrading requests fixed this for them: version 2.25.1 didn't work, but 2.23.0 did. They're on python 3.7.7 on windows.

@vzRowan
Copy link

vzRowan commented Dec 24, 2020

I haven't tested this, but I got an email from someone who claims downgrading requests fixed this for them: version 2.25.1 didn't work, but 2.23.0 did. They're on python 3.7.7 on windows.

Quick question, what do you mean with "downgrading requests" ?

@simon-weber
Copy link
Owner

I'm referring to requests, which is a dependency of gpsoauth. ie, try pip install requests==2.23.0.

@kiwiz
Copy link
Contributor

kiwiz commented Dec 29, 2020

Looking at a diff of v2.23.0 - v2.25.1, this change seems suspect. Might take a closer look at this if I've time.

@jkuebart
Copy link
Contributor

jkuebart commented Feb 2, 2021

@simon-weber FWIW it started working for me after downgrading from requests-2.25.1 to 2.23.0, but is now still working after upgrading back to 2.25.1. puzzled

@simon-weber
Copy link
Owner

Haha, yeah, I don't know what's going on either. If someone can pin down the problem or which versions definitely do and don't work I can change the package requirements. I'm hesitant to mess with it, especially now that pip is more aggressive about conflicts.

@jkuebart
Copy link
Contributor

jkuebart commented Feb 2, 2021

I was in the process of bisecting to find what broke it – but now I can't 'cause it's working :-\

@HIT2022
Copy link

HIT2022 commented Feb 2, 2021

@simon-weber FWIW it started working for me after downgrading from requests-2.25.1 to 2.23.0, but is now still working after upgrading back to 2.25.1. puzzled

Same here.

@simon-weber
Copy link
Owner

Hm. Well, it's always possible we're dealing with something weird on Google's end. Maybe they have automated systems to block user agents; I think those depend on both the python version and the requests version.

@DurgNomis-drol
Copy link

I have the exact same problem, downgrading and upgrading again solves the issue. Can it be that a dependency bundled with 2.25.1 (when you first installs it) creates a weird problem with how google handles the login but when you downgrade and then upgrade again it only upgrades some of the packages because only som og them ære required to be new, but others are allowed to be older (but newer ones are installed the first time)
Or am I too far gone i my thoughts?

I have this problem on Homeassistant in docker on an Arm/Alpine image (stock image for Homeassistant)

@simon-weber
Copy link
Owner

Could be! What's the diff in packages between the downgrade/upgrades?

@DurgNomis-drol
Copy link

DurgNomis-drol commented Feb 4, 2021

See this log.

urlib3 is downgraded but not upgraded again

If there is a better way to include this log info below, please let me know. Im new to github

`bash-5.0# pip install requests==2.24.0
Collecting requests==2.24.0
Downloading requests-2.24.0-py2.py3-none-any.whl (61 kB)
|████████████████████████████████| 61 kB 191 kB/s
Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.8/site-packages (from requests==2.24.0) (2.10)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.8/site-packages (from requests==2.24.0) (2020.12.5)
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1
Downloading urllib3-1.25.11-py2.py3-none-any.whl (127 kB)
|████████████████████████████████| 127 kB 5.1 MB/s
Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.8/site-packages (from requests==2.24.0) (3.0.4)
Installing collected packages: urllib3, requests
Attempting uninstall: urllib3
Found existing installation: urllib3 1.26.3
Uninstalling urllib3-1.26.3:
Successfully uninstalled urllib3-1.26.3
Attempting uninstall: requests
Found existing installation: requests 2.25.1
Uninstalling requests-2.25.1:
Successfully uninstalled requests-2.25.1
ERROR: After October 2020 you may experience errors when installing or updating packages. This is because pip will change the way that it resolves dependency conflicts.

We recommend you use --use-feature=2020-resolver to test your packages with the new resolver before it becomes the default.

samsungtvws 1.4.0 requires websocket-client==0.56.0, but you'll have websocket-client 0.54.0 which is incompatible.
roonapi 0.0.31 requires websocket_client>=0.57.0, but you'll have websocket-client 0.54.0 which is incompatible.
pyrebase4 4.4.3 requires oauth2client>=4.1.2, but you'll have oauth2client 4.0.0 which is incompatible.
pyicloud 0.9.7 requires click<=7.1.1,>=6.0, but you'll have click 7.1.2 which is incompatible.
pyicloud 0.9.7 requires keyring<=9.3.1,>=8.0, but you'll have keyring 21.2.0 which is incompatible.
pyicloud 0.9.7 requires keyrings.alt<=3.2.0,>=1.0, but you'll have keyrings-alt 3.4.0 which is incompatible.
pycognito 0.1.5 requires boto3>=1.10.49, but you'll have boto3 1.9.252 which is incompatible.
meteofrance-api 1.0.1 requires pytz<2021.0,>=2020.4, but you'll have pytz 2021.1 which is incompatible.
meteofrance-api 1.0.1 requires requests<3.0.0,>=2.25.0, but you'll have requests 2.24.0 which is incompatible.
locationsharinglib 4.1.5 requires requests>=2.25.1, but you'll have requests 2.24.0 which is incompatible.
ibm-watson 4.0.1 requires websocket-client==0.48.0, but you'll have websocket-client 0.54.0 which is incompatible.
homematicip 0.13.1 requires websocket-client>=0.57.0, but you'll have websocket-client 0.54.0 which is incompatible.
hangups 0.4.11 requires protobuf<3.12,>=3.1.0, but you'll have protobuf 3.14.0 which is incompatible.
eebrightbox 0.0.4 requires certifi==2018.11.29, but you'll have certifi 2020.12.5 which is incompatible.
eebrightbox 0.0.4 requires idna==2.8, but you'll have idna 2.10 which is incompatible.
eebrightbox 0.0.4 requires requests==2.21.0, but you'll have requests 2.24.0 which is incompatible.
eebrightbox 0.0.4 requires urllib3==1.24.1, but you'll have urllib3 1.25.11 which is incompatible.
botocore 1.13.14 requires python-dateutil<2.8.1,>=2.1; python_version >= "2.7", but you'll have python-dateutil 2.8.1 which is incompatible.
boto3 1.9.252 requires botocore<1.13.0,>=1.12.252, but you'll have botocore 1.13.14 which is incompatible.
homeassistant 2021.2.0 requires requests==2.25.1, but you'll have requests 2.24.0 which is incompatible.
Successfully installed requests-2.24.0 urllib3-1.25.11
WARNING: You are using pip version 20.2.4; however, version 21.0.1 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
bash-5.0# pip install requests==2.23.0
Collecting requests==2.23.0
Downloading requests-2.23.0-py2.py3-none-any.whl (58 kB)
|████████████████████████████████| 58 kB 852 kB/s
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.8/site-packages (from requests==2.23.0) (2020.12.5)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.8/site-packages (from requests==2.23.0) (1.25.11)
Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.8/site-packages (from requests==2.23.0) (2.10)
Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.8/site-packages (from requests==2.23.0) (3.0.4)
Installing collected packages: requests
Attempting uninstall: requests
Found existing installation: requests 2.24.0
Uninstalling requests-2.24.0:
Successfully uninstalled requests-2.24.0
ERROR: After October 2020 you may experience errors when installing or updating packages. This is because pip will change the way that it resolves dependency conflicts.

We recommend you use --use-feature=2020-resolver to test your packages with the new resolver before it becomes the default.

synologydsm-api 1.0.1 requires requests<3.0.0,>=2.24.0, but you'll have requests 2.23.0 which is incompatible.
surepy 0.4.0 requires requests==2.*,>=2.24.0, but you'll have requests 2.23.0 which is incompatible.
samsungtvws 1.4.0 requires websocket-client==0.56.0, but you'll have websocket-client 0.54.0 which is incompatible.
roonapi 0.0.31 requires websocket_client>=0.57.0, but you'll have websocket-client 0.54.0 which is incompatible.
pyrebase4 4.4.3 requires oauth2client>=4.1.2, but you'll have oauth2client 4.0.0 which is incompatible.
pyicloud 0.9.7 requires click<=7.1.1,>=6.0, but you'll have click 7.1.2 which is incompatible.
pyicloud 0.9.7 requires keyring<=9.3.1,>=8.0, but you'll have keyring 21.2.0 which is incompatible.
pyicloud 0.9.7 requires keyrings.alt<=3.2.0,>=1.0, but you'll have keyrings-alt 3.4.0 which is incompatible.
pycognito 0.1.5 requires boto3>=1.10.49, but you'll have boto3 1.9.252 which is incompatible.
pyatmo 4.2.2 requires requests~=2.24, but you'll have requests 2.23.0 which is incompatible.
meteofrance-api 1.0.1 requires pytz<2021.0,>=2020.4, but you'll have pytz 2021.1 which is incompatible.
meteofrance-api 1.0.1 requires requests<3.0.0,>=2.25.0, but you'll have requests 2.23.0 which is incompatible.
locationsharinglib 4.1.5 requires requests>=2.25.1, but you'll have requests 2.23.0 which is incompatible.
ibm-watson 4.0.1 requires websocket-client==0.48.0, but you'll have websocket-client 0.54.0 which is incompatible.
homematicip 0.13.1 requires requests>=2.24.0, but you'll have requests 2.23.0 which is incompatible.
homematicip 0.13.1 requires websocket-client>=0.57.0, but you'll have websocket-client 0.54.0 which is incompatible.
hangups 0.4.11 requires protobuf<3.12,>=3.1.0, but you'll have protobuf 3.14.0 which is incompatible.
eebrightbox 0.0.4 requires certifi==2018.11.29, but you'll have certifi 2020.12.5 which is incompatible.
eebrightbox 0.0.4 requires idna==2.8, but you'll have idna 2.10 which is incompatible.
eebrightbox 0.0.4 requires requests==2.21.0, but you'll have requests 2.23.0 which is incompatible.
eebrightbox 0.0.4 requires urllib3==1.24.1, but you'll have urllib3 1.25.11 which is incompatible.
blinkpy 0.16.4 requires requests>=2.24.0, but you'll have requests 2.23.0 which is incompatible.
homeassistant 2021.2.0 requires requests==2.25.1, but you'll have requests 2.23.0 which is incompatible.
Successfully installed requests-2.23.0
WARNING: You are using pip version 20.2.4; however, version 21.0.1 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
bash-5.0# pip install requests
Requirement already satisfied: requests in /usr/local/lib/python3.8/site-packages (2.23.0)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.8/site-packages (from requests) (2020.12.5)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.8/site-packages (from requests) (1.25.11)
Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.8/site-packages (from requests) (2.10)
Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.8/site-packages (from requests) (3.0.4)
WARNING: You are using pip version 20.2.4; however, version 21.0.1 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.`

@simon-weber
Copy link
Owner

Nice find. My diff of pip freeze after pip install gpsoauth and then a pip install requests==2.23.0 is:

chardet 4.0.0 -> 3.0.4
requests 2.25.1 -> 2.23.0
urllib3 1.26.3 -> 1.25.11

So, if someone's got a repro of the problem, maybe try downgrading chardet and then urllib individually to see if either of those alone fix it.

@DurgNomis-drol
Copy link

A quick test showed me that if urllib3 is larger then 1.25.11 it will fail with invalid oauth credentials.

They made a couple of changes to how urllib3 works in 1.26.0 see: urllib3
It's probably something to do with how they change the way it handles user-agents or headers or maybe even tls/ssl.

@simon-weber
Copy link
Owner

Yup, it looks like that's it! It seems like some unknown interaction between some new urllib3 options and Google: urllib3/urllib3#2101.

It doesn't look like there's any workaround right now, so I guess I should just disallow urllib3>1.25.11 for now.

@DurgNomis-drol
Copy link

We can only hope that Google fixes it on there end at some point

Have a nice day

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

Successfully merging a pull request may close this issue.

11 participants