Automation Google login with python and selenium shows “”This browser or app may be not secure””

We Are Going To Discuss About Automation Google login with python and selenium shows “”This browser or app may be not secure””. So lets Start this Python Article.

Automation Google login with python and selenium shows “”This browser or app may be not secure””

  1. How to solve Automation Google login with python and selenium shows “”This browser or app may be not secure””

    First of all don't use chrome and chromedriver. You need to use Firefox.(if not installed) Download and install Firefox. Login to Google with normal Firefox.
    You need to show the Google site that you are not a robot. You can use code like this:
    from selenium import webdriver import geckodriver_autoinstaller from selenium.webdriver.common.desired_capabilities import DesiredCapabilities geckodriver_autoinstaller.install() profile = webdriver.FirefoxProfile( '/Users/<user name>/Library/Application Support/Firefox/Profiles/xxxxx.default-release') profile.set_preference("dom.webdriver.enabled", False) profile.set_preference('useAutomationExtension', False) profile.update_preferences() desired = DesiredCapabilities.FIREFOX driver = webdriver.Firefox(firefox_profile=profile, desired_capabilities=desired)
    This can help you find your profile location.
    But, why Firefox?
    Actually there is only one reason, chromedriver was coded by Google.
    They can easily understand if it is a bot or not. But when we add user data with Firefox, they cannot understand if there is a bot or not.
    You can fool Google like this. It worked for me too. I tried very hard to do this. Hope it will be resolved in you too.

  2. Automation Google login with python and selenium shows “”This browser or app may be not secure””

    First of all don't use chrome and chromedriver. You need to use Firefox.(if not installed) Download and install Firefox. Login to Google with normal Firefox.
    You need to show the Google site that you are not a robot. You can use code like this:
    from selenium import webdriver import geckodriver_autoinstaller from selenium.webdriver.common.desired_capabilities import DesiredCapabilities geckodriver_autoinstaller.install() profile = webdriver.FirefoxProfile( '/Users/<user name>/Library/Application Support/Firefox/Profiles/xxxxx.default-release') profile.set_preference("dom.webdriver.enabled", False) profile.set_preference('useAutomationExtension', False) profile.update_preferences() desired = DesiredCapabilities.FIREFOX driver = webdriver.Firefox(firefox_profile=profile, desired_capabilities=desired)
    This can help you find your profile location.
    But, why Firefox?
    Actually there is only one reason, chromedriver was coded by Google.
    They can easily understand if it is a bot or not. But when we add user data with Firefox, they cannot understand if there is a bot or not.
    You can fool Google like this. It worked for me too. I tried very hard to do this. Hope it will be resolved in you too.

Solution 1

First of all don’t use chrome and chromedriver. You need to use Firefox.(if not installed) Download and install Firefox. Login to Google with normal Firefox.

You need to show the Google site that you are not a robot. You can use code like this:

from selenium import webdriver
import geckodriver_autoinstaller
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

geckodriver_autoinstaller.install()

profile = webdriver.FirefoxProfile(
    '/Users/<user name>/Library/Application Support/Firefox/Profiles/xxxxx.default-release')

profile.set_preference("dom.webdriver.enabled", False)
profile.set_preference('useAutomationExtension', False)
profile.update_preferences()
desired = DesiredCapabilities.FIREFOX

driver = webdriver.Firefox(firefox_profile=profile,
                           desired_capabilities=desired)

This can help you find your profile location.

But, why Firefox?

Actually there is only one reason, chromedriver was coded by Google.
They can easily understand if it is a bot or not. But when we add user data with Firefox, they cannot understand if there is a bot or not.

You can fool Google like this. It worked for me too. I tried very hard to do this. Hope it will be resolved in you too.

Original Author yusufusta Of This Content

Solution 2

This is working for me. I found the solution from GitHub.

   from selenium import webdriver
   from selenium_stealth import stealth

   options = webdriver.ChromeOptions()
   options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36")
   options.add_experimental_option("excludeSwitches", ["enable-automation"])
   options.add_experimental_option('useAutomationExtension', False)
   options.add_argument('--disable-blink-features=AutomationControlled')
   driver = webdriver.Chrome(options=options)
   stealth(driver,
        languages=["en-US", "en"],
        vendor="Google Inc.",
        platform="Win32",
        webgl_vendor="Intel Inc.",
        renderer="Intel Iris OpenGL Engine",
        fix_hairline=True,
        )
   driver.get("https://www.google.com")

Original Author Praveen Kumar Of This Content

Solution 3

You can easily bypass the google bot detection with the undetected_chromedriver:

pip install undetected_selenium
pip install selenium

Credits: https://github.com/xtekky/google-login-bypass/blob/main/login.py

import undetected_chromedriver as uc
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

#  ---------- EDIT ----------
email = 'email\n' # replace email
password = 'password\n' # replace password
#  ---------- EDIT ----------

driver = uc.Chrome(use_subprocess=True)
wait = WebDriverWait(driver, 20)
url = 'https://accounts.google.com/ServiceLogin?service=accountsettings&continue=https://myaccount.google.com%3Futm_source%3Daccount-marketing-page%26utm_medium%3Dgo-to-account-button'
driver.get(url)


wait.until(EC.visibility_of_element_located((By.NAME, 'identifier'))).send_keys(email)
wait.until(EC.visibility_of_element_located((By.NAME, 'password'))).send_keys(password)
print("You're in!! enjoy")

Original Author xtekky Of This Content

Solution 4

From terminal pip install undetected-chromedriver
then do the following steps, as shown below.
NOTE: indent your code inside if name == main, as i have done, only then the program will work

import undetected_chromedriver as uc
from time import sleep
from selenium.webdriver.common.by import By


if __name__ == '__main__':
    
    driver = uc.Chrome()
    driver.get('https://accounts.google.com/')

    # add email
    driver.find_element(By.XPATH, '//*[@id="identifierId"]').send_keys(YOUR EMAIL)
    driver.find_element(By.XPATH, '//*[@id="identifierNext"]/div/button/span').click()
    sleep(3)
    driver.find_element(By.XPATH, '//*[@id="password"]/div[1]/div/div[1]/input').send_keys(YOUR PASSWORD)
    driver.find_element(By.XPATH, '//*[@id="passwordNext"]/div/button/span').click()
    sleep(10)


Original Author Salim muneer lala Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

ittutorial team

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment