11
votes

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.

Image link

2
I have found that the problem has a lot to do with the public IPs of Google Compute Engine: 1. I create a VPN with an ssh tunnel: ssh -D 9090 -C -q -N userserver@iphostserver 2. I configure the chrome/firefox browser proxy (with web-driver) 3. User login and password, and I get the same result (now ask captcha) > Note (1): Nested virtualization is same problem (Virtualbox in GCE) > Note (2): In AWS it works correctly.Oscar Oswaldo Ortiz Perez
I have the same issue, have you found the solution since ?SciPy
Other workarounds that didn't work : Mobile emulation + proxy/vpn + new userAgent + Alternate webdriver (e.g. PhantomJS) --> return also a captcha codeSciPy
Also didn't work: login in local / save cookies & data-dir (i.e. Session information) / and in Google cloud import cookies and data-dir in the webdriverSciPy

2 Answers

3
votes

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.

2
votes

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.