Google login fails with HTTP error 400 saying "Sorry, something went wrong there. Try again."

Viewed 2861

Description/background

I had set up a script which opened a Google site of our company in Google Chrome (not headless) and did some automated work on that page. The login information had to be refreshed occasionally what for I manually logged in. That had been working perfectly the last couple of months until last week. Today I noticed that I get the above mentioned error message as a result of a server response with HTTP status 400 upon entering my Gmail address and clicking the Next button.

Steps to reproduce

Puppeteer version: 2.0.0
Platform / OS version: Windows 10
URLs (if applicable): https://sites.google.com/...
Node.js version: v12.13.0

What steps will reproduce the problem?

  1. Run a Puppeteer script to open a Google Site which requires login.

    (async () => {
    try {
    const browser = await puppeteer.launch({headless: false, userDataDir: "<ProfileDirectory>"});
    const pageLogin = await browser.newPage();
    await pageLogin.goto('https://sites.google.com/...', {waitUntil: 'networkidle2'});
    ...
    await browser.close();
    }
    catch (error) {
    console.log(error.stacktrace);
    }
    })();
    
  2. Manually enter Gmail address and click Next.

  3. Get error message "Sorry, something went wrong there. Try again." as a result of a server response with HTTP status code 400.

Update:

Manually opening Chrome (same userDataDir) and the respective Google site still works as usual.

3 Answers

Recommend to use playwright/puppeteer + Firefox. It seems like google adds something into chrome so they can detect the browser is automated or not

One of the comments on this post mentions that Google tries to block logins with Puppeteer, Selenium etc. this might be why you are getting a 400 error.

One of the recent comments on the aforementioned post, links a gist with some example code that might still work, haven't tried it though.

While I was doing research on Puppeteer for Firefox, I noticed that (1) Puppeteer downloads its own local Google Chrome binaries it is executing and (2) my installed Puppeteer version 2.0.0 was outdated. Meaning, the browser actually used by Puppeteer was probably also outdated. The solution was as easy as to update Puppeteer to the latest version 2.1.1.

Related