Skip to content

Instantly share code, notes, and snippets.

@ikegami-yukino
Created June 12, 2015 09:26
Show Gist options
  • Star 55 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save ikegami-yukino/51b247080976cb41fe93 to your computer and use it in GitHub Desktop.
Save ikegami-yukino/51b247080976cb41fe93 to your computer and use it in GitHub Desktop.
Automatically Google login by selenium
mail_address = ''
password = ''
from selenium import webdriver
UA = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0'
PHANTOMJS_ARG = {'phantomjs.page.settings.userAgent': UA}
driver = webdriver.PhantomJS(desired_capabilities=PHANTOMJS_ARG)
url = 'https://www.google.com/accounts/Login?hl=ja&continue=http://www.google.co.jp/'
driver.get(url)
driver.find_element_by_id("Email").send_keys(mail_address)
driver.find_element_by_id("next").click()
driver.find_element_by_id("Passwd").send_keys(password)
driver.find_element_by_id("signIn").click()
@Fakesum
Copy link

Fakesum commented Apr 27, 2024

its been more than a month but if you still, for whatever reason, need to contact me, you can do so on discord with the tag hello215

@Fakesum Does this method only work locally? I am trying to standup some tests on jenkins but after entering the password this way, I'm then redirected to https://accounts.google.com/v3/signin/challenge/iap and cannot complete the auth flow.
works well locally though
EDIT: https://accounts.google.com/v3/signin/challenge/iap is a 2FA challenge for accounts that don't have 2FA enabled, to set it up in-line. Likely will need to forward proxy and that potentially won't help either.

This works locally for me, it does give me a warning of suspicious activity but thats after logging in. try changing the url to "https://accounts.google.com/signin" since this will redirect to oauth v3 login screen instead of the old oauth v2 one.

hey bro, can i contact you somewhere else? i really need your help

Its been more than a month, but if you still need to contant me, you can do so on hello215 on discord

@dattv02
Copy link

dattv02 commented Apr 27, 2024

its been more than a month but if you still, for whatever reason, need to contact me, you can do so on discord with the tag hello215

@Fakesum Does this method only work locally? I am trying to standup some tests on jenkins but after entering the password this way, I'm then redirected to https://accounts.google.com/v3/signin/challenge/iap and cannot complete the auth flow.
works well locally though
EDIT: https://accounts.google.com/v3/signin/challenge/iap is a 2FA challenge for accounts that don't have 2FA enabled, to set it up in-line. Likely will need to forward proxy and that potentially won't help either.

This works locally for me, it does give me a warning of suspicious activity but thats after logging in. try changing the url to "https://accounts.google.com/signin" since this will redirect to oauth v3 login screen instead of the old oauth v2 one.

hey bro, can i contact you somewhere else? i really need your help

Its been more than a month, but if you still need to contant me, you can do so on hello215 on discord

Hi Guy. You can help me login google with python?
I have added your discord account. Thank bro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment