I have automated tests of UI with Selenium, The first step is to enter a Google account (username and password, the account does not require anything else). These tests run well on my personal computer, but when I try to run them on a virtual machine in Compute Engine with chrome / firefox etc. After entering email and password, Google returns the following message:
“For your protection, you can’t sign in from this device. Try again later, or sign in from another device.”
Additional notes:
-
I have already tried several accounts; Gmail (personal / standard and with G Suite) and the same thing happens (Selenium + Compute Engine)
-
In Compute Engine machines I can enter traditionally / manually well,no problem. The problem arises when I run the script with Selenum (webdrive chrome and firefox).
-
The OS Centos 7 + xfce, selenium node js
-
UserAgent: “Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.87 Safari/537.36”
I attach the image, I appreciate any help.
2
Answers
I’m not positive this will help, but I notice your user-agent looks unconventional, reporting Safari and WebKit on Linux.
I know in my Firefox on MacOS, I have an extension that spoofs my user-agent with strings that I know for sure are valid but don’t match my actual setup, and I reliably get that same error trying to log into my Google account unless I turn that extension off. I believe Google may be using Javascript to do some fingerprinting, and then refusing to allow logins at all if the user-agent string doesn’t match what it finds, and returns only that vague message that I “can’t sign in from this device.”
Maybe you could try setting your user-agent string to something more common or appropriate for your OS and browser.
Possibly not related with your use case. But I started to encounter this 3 weeks ago myself on a regular Windows 7 Home using Firefox Developer as my browser.
The solution offered by @john-smith (which was voted down) gave me an idea as I am using a custom user-agent for this browser. I reverted the user-agent back to normal and I was able to login to all of the Google services again.
Whoever voted down @john-smith’s answer did so without actually testing it first or understanding it. But it appears that Google probably started to blacklist user-agents that are old or unknown to them or they find suspicious.
If it is also a user-agent issue on your end, then this is more on Google’s end.
I hope it helps.
And thanks to @john-smith, his solution gave me an idea and it worked. Unfortunately, I can’t up-vote you because of the restrictions in place.