0

I am using selenium to open and sign into google accounts as my first step. I have successfully opened and filled the email response although upon submitting I receive the error of

"This browser or app may not be secure. Learn more Try using a different browser. If you’re already using a supported browser, you can refresh your screen and try again to sign in." From google.

Is there any way to get around this? Here is my code below.


from selenium import webdriver

from selenium.webdriver.common.keys import Keys

import time

PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)

driver.get("https://accounts.google.com/")
print(driver.title)

search = driver.find_element_by_name("identifier")

search.send_keys("email goes here")

search.send_keys(Keys.RETURN)
Nandan A
  • 2,702
  • 1
  • 12
  • 23
  • You can once refer this [gmail](https://stackoverflow.com/q/57602974/16452840) – pmadhu Jul 24 '21 at 05:40
  • Does this answer your question? [“This browser or app may not be secure” error while attempting to login in to Gmail account using GeckoDriver Firefox through Selenium and Python](https://stackoverflow.com/questions/59515561/this-browser-or-app-may-not-be-secure-error-while-attempting-to-login-in-to-gm) – questioning Nov 29 '21 at 10:37

1 Answers1

0

Was having the same issue and i found this thread in GitHub.

The solution that worked for me was to use this driver: undetected_chromedriver instead of the normal ChromeDriver.

    import undetected_chromedriver.v2 as uc

    chrome_options = uc.ChromeOptions()
    chrome_options.add_argument("--disable-extensions")
    chrome_options.add_argument("--disable-popup-blocking")
    chrome_options.add_argument("--profile-directory=Default")
    chrome_options.add_argument("--disable-plugins-discovery")
    chrome_options.add_argument("--incognito")
    chrome_options.add_argument("user_agent=DN")

    self.browser = uc.Chrome(options=chrome_options)
    self.browser.delete_all_cookies()

    # example of loggin in to youtube without getting that issue
    self.browser.get('http://youtube.com')

    login_button_init = self.browser.find_element_by_xpath("//a[@aria-label='Sign in']") 
    login_button_init.click()

    # locate the login button
    login_button = self.browser.find_element_by_xpath("//paper-button[@aria-label='Sign in']")
    login_button.click()

    # get email and set to email input box
    email = self.browser.find_element_by_id("identifierId")
    myemail = os.environ.get('YOUTUBE_EMAIL')
    email.send_keys(myemail)

    # click next button
    email_next_button = self.browser.find_element_by_id("identifierNext")
    email_next_button.click()

    # get password and set to password input box
    password = self.browser.find_element_by_name("password")
    mypassword = os.environ.get('YOUTUBE_PASSWORD')
    password.send_keys(mypassword)
    sleep(2)

    # click next button to log in
    pass_next_button = self.browser.find_element_by_id("passwordNext")
    pass_next_button.click()
Marialena
  • 817
  • 8
  • 31