Python Forum
Not able to sign into gmail using selenium
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Not able to sign into gmail using selenium
#1
I am trying to automate gmail by downloading attachments from my inbox using selenium. But, it is showing me this error "This browser or app may not be secure". I looked around and found that OAuth will solve the problem. But, I don't know how to use it or if it is the right tool to use. Can anyone help me solve this error. Is Oauth the right tool? Will using any other browser solve the problem?

I am getting the Options() because I am not able to open chrome as it is not in the default location. If you have a solution for that too. Thanks

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.binary_location = "/opt/google/chrome/google-chrome"    
options.add_argument("--start-maximized") 
options.add_argument("--no-sandbox") #bypass OS security model
options.add_argument("--disable-dev-shm-usage") 

options.add_experimental_option("excludeSwitches["enableautomation"])
options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(options=options, 
executable_path=r'./chromedriver')
driver.get('http://gmail.com/')
Error that is shown by gmail: 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.
Reply
#2
Out of interest, why Selenium? Gmail has a REST API, which does seem to have an endpoint for getting attachments.
Reply
#3
Just enable less secure apps on Gmail and use their API, but if you really need to use selenium Google blocks bots from what I've experienced.
Reply
#4
(Nov-18-2020, 06:31 AM)ndc85430 Wrote: Out of interest, why Selenium? Gmail has a REST API, which does seem to have an endpoint for getting attachments.

I want the attachments as Zip. and I don't know if it has an option for it. But, I will be trying the API. Thanks
Reply
#5
(Nov-18-2020, 11:51 AM)Anarab Wrote: Just enable less secure apps on Gmail and use their API, but if you really need to use selenium Google blocks bots from what I've experienced.

I have seen people do it and also found people do it using Oauth here: https://gist.github.com/ikegami-yukino/5...76cb41fe93 . But, surely I will be trying the API and see if there is any problem. And Do I need any authorization for accessing my Gmail? using the API.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Gmail API - Error 400: redirect_uri_mismatch Depp 1 1,542 Jun-12-2022, 10:42 AM
Last Post: snippsat
  find a hyperlink in Gmail body python 3(imap and selenium) taomihiranga 1 8,117 Dec-30-2020, 05:31 PM
Last Post: Gamer1057
  How to send notifications to gmail from contact form using Django and pushbullet Justchse 0 1,841 Sep-01-2020, 01:19 PM
Last Post: Justchse
  Send email to gmail after user fill up contact form and getting django database updat Man_from_India 0 2,071 Jan-22-2020, 03:59 PM
Last Post: Man_from_India
  Error in Selenium: CRITICAL:root:Selenium module is not installed...Exiting program. AcszE 1 3,587 Nov-03-2017, 08:41 PM
Last Post: metulburr
  How to enter value in gmail id and password ratanbhushan 5 6,696 Nov-02-2017, 11:49 AM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020