Login failed
I'm using 2FA and when I try and login using pyportify and an app password generated from https://security.google.com/settings/security/apppasswords
I get a "Login failed". I've also tried using the command line with the same error.
Does anyone have any ideas? Is there some way to generate a log with pyportify?
Edit: I check the google audit logs (https://admin.google.com/AdminHome?fral=1#Reports:subtab=login-audit) and there doesn't appear to be an attempt to login.
Facing the same issue.
Wait... So this happens only in my office network and I am able to login to google account in my home network. So @gyrex try to login by turning off your VPN if you are on one.
Same Here.
Same with me even on home network without VPN
This works fine for me. I wonder, are you trying to use a G Suite account? I'm using a gmail account and app passwords works fine.
Basic Gmail account for me. Once I added 2fa and used app passwords it worked. Was getting Login Failed using the basic Gmail account and home connection beforehand.
Solution that worked for me:
-
On your android device, find your Android Device ID (I used this app to find it)
-
On line 25 in
$PYTHON_PATH/site_packages/pyportify/google.pyreplaceandroid_id = _get_android_id()with
android_id = "YOUR_ANDROID_DEVICE_ID".upper()
@anantkamath ^ worked for me. Thanks !!
I also faced an SSL issue with Spotify, and add verify_ssl=False here helped (app.py):
with ClientSession(connector=aiohttp.TCPConnector(verify_ssl=False)) as session:
In my case, I had to:
- temporarily turn ON "Less secure Apps" on this page
- "Allow access to your Google Account" on that page.
After that I was able to log in to my Google account.
Hope it helps.
instead of disabling 2FA and/or exposing your Google account to less secure apps, use a Google App Password, which you can generate specifically for this app and then discard/disable it when you're done.
running into this exact issue with a G-Suite account. Using an app password and/or allowing access to my account doesn't work, trying to log in still throws the login failed error. I've had 2FA turned on since 2013, and it's looking like the only way to use pyportify with a 2FA enabled G-Suite account is to temporarily disable it.
edit: still can't log in to my G-Suite account using the account password after disabling 2FA. I've done a little debugging and troubleshooting. Came across https://developers.google.com/gdata/docs/auth/clientlogin and found this note:
Note: By default, the client libraries set an account-type parameter to HOSTED_OR_GOOGLE. That means ClientLogin will first try to authenticate the user's credentials as a G Suite account. If that fails, it will try to authenticate as a Google Account. This becomes tricky if [email protected] is both a Google Account and a G Suite account. In that special case, set the account type to GOOGLE if the user wishes to use the Google Accounts version of [email protected].
I changed all off the accountType references to 'GOOGLE' to see if it made a difference (it didn't). I started setting some breakpoints and eventually narrowed the issue to gpsoauth.perform_oauth. Ultimately, Google is returning error 403 DeviceManagementRequiredOrSyncDisabled. I haven't looked up that error yet, but I'll post an update if I'm able to get past it.
Alright, looks like I figured it out. I've got one of those free legacy G-Suite plans, which is part of the problem here. The default mobile management setting is set to "basic", which seems to be too basic and throws the DeviceManagementRequiredOrSyncDisabled error when trying to login.

The "advanced" setting looks like it might fix this, but since it's not available for for the legacy plan, shutting off mobile management entirely allows me to log in with a 2FA app password. The URL for the mobile management page is https://admin.google.com/AdminHome?hl=en#MobileSettings:section=setup&flyout=setup.