Unable to sign into google with selenium automation because of "This browser or app may not be secure."

The followings work me as well: 1. try to login stackoverflow with your google account 2. once login, go to the email

here is solution

     WebDriver driver;
    System.setProperty("webdriver.chrome.driver", "chromeDriver/chromedriver.exe");
    driver = new ChromeDriver();
     GeneralClass te =  new GeneralClass ();

    driver.get("https://accounts.google.com/signin/oauth/identifier?client_id=717762328687-iludtf96g1hinl76e4lc1b9a82g457nn."
            + "apps.googleusercontent.com&as=JS6BM8cjL-8j9votansdkw&destination=https%3A%2F%2Fstackauth"
            + ".com&approval_state=!ChRoYWVvLUlNMk5hSXJWUGlaSVl2WBIfc3lSa0lueENpb29lSU5vbEVpbVNxcUZGaGNkSEJoYw%E2%88%99AJDr988AAAAAXlBKc7PzEomxSzgNqd4wLptVlf0Ny3Qx&oauthgdpr=1&xsrfsig=ChkAeAh8T8JNDxCf2Zah5fb_rQ55OMiF8KmMEg5hcHByb3ZhbF9zdGF0ZRILZGVzdGluYXRpb24SBXNvYWN1Eg9vYXV0aHJpc2t5c2NvcGU&flowName=GeneralOAuthFlow");
     te.waitingForElementSendingKey(driver, By.id("identifierId"), "[email protected]");
     te.waitingForElementForClickOnly(driver, By.id("identifierNext"));
     te.waitingForElementSendingKey(driver,By.name("password"), "PASSSWORD");
     te.waitingForElementForClickOnly(driver, By.id("passwordNext"));
     Thread.sleep(1500);
     driver.get("https://mail.google.com/mail/u/0/#inbox");

Thanks


I just tried something out that worked for me after several hours of trial and error.

Adding args: ['--disable-web-security', '--user-data-dir', '--allow-running-insecure-content' ] to my config resolved the issue.

I realized later that this was not what helped me out as I tried with a different email and it didn't work. After some observations, I figured something else out and this has been tried and tested.

Using automation:

Go to https://stackoverflow.com/users/login Select Log in with Google Strategy Enter Google username and password Login to Stackoverflow Go to https://gmail.com (or whatever Google app you want to access)

After doing this consistently for like a whole day (about 24 hours), try automating your login directly to gmail (or whatever Google app you want to access) directly... I've had at least two other people do this with success. PS - You might want to continue with the stackoverflow login until you at least get a captcha request as we all went through that phase as well.