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() |
I've created a script to help people automate Google login here: https://github.com/crawlspec/google-login
It only needs the phone number for 2FA on first use. Subsequent uses will be 'trusted' by the service. It's written in puppeteer javascript. I can write a python selenium version if there's demand. Let me know if it works for you or post in the project's 'Issues' tab for any questions.
@kicktheken
I would appreciate a python selenium version.
i've tried using it and it didn't work (i don't know if i did it wrong or not)
Current Best Method for google login is:
from seleniumbase import SB
with SB(uc=True) as driver:
driver.get("https://accounts.google.com/o/oauth2/v2/auth/oauthchooseaccount?redirect_uri=https%3A%2F%2Fdevelopers.google.com%2Foauthplayground&prompt=consent&response_type=code&client_id=407408718192.apps.googleusercontent.com&scope=email&access_type=offline&flowName=GeneralOAuthFlow")
driver.type("#identifierId", <Your Username Here>)
driver.click("#identifierNext > div > button")
driver.type("#password > div.aCsJod.oJeWuf > div > div.Xb9hP > input", <Password Here>)
driver.click("#passwordNext > div > button")
driver.save_screenshot("test.png")
I can't figure out how to make the window show though.
Current Best Method for google login is:
from seleniumbase import SB with SB(uc=True) as driver: driver.get("https://accounts.google.com/o/oauth2/v2/auth/oauthchooseaccount?redirect_uri=https%3A%2F%2Fdevelopers.google.com%2Foauthplayground&prompt=consent&response_type=code&client_id=407408718192.apps.googleusercontent.com&scope=email&access_type=offline&flowName=GeneralOAuthFlow") driver.type("#identifierId", <Your Username Here>) driver.click("#identifierNext > div > button") driver.type("#password > div.aCsJod.oJeWuf > div > div.Xb9hP > input", <Password Here>) driver.click("#passwordNext > div > button") driver.save_screenshot("test.png")I can't figure out how to make the window show though.
it worked.
Use This if you want head-full mode.
from seleniumbase import SB
with SB(uc=True, headed=True) as driver:
driver.get("https://accounts.google.com/o/oauth2/v2/auth/oauthchooseaccount?redirect_uri=https%3A%2F%2Fdevelopers.google.com%2Foauthplayground&prompt=consent&response_type=code&client_id=407408718192.apps.googleusercontent.com&scope=email&access_type=offline&flowName=GeneralOAuthFlow")
driver.type("#identifierId", <Your Username Here>)
driver.click("#identifierNext > div > button")
driver.type("#password > div.aCsJod.oJeWuf > div > div.Xb9hP > input", <Password Here>)
driver.click("#passwordNext > div > button")
driver.save_screenshot("test.png")
Use This if you want head-full mode.
from seleniumbase import SB with SB(uc=True, headed=True) as driver: driver.get("https://accounts.google.com/o/oauth2/v2/auth/oauthchooseaccount?redirect_uri=https%3A%2F%2Fdevelopers.google.com%2Foauthplayground&prompt=consent&response_type=code&client_id=407408718192.apps.googleusercontent.com&scope=email&access_type=offline&flowName=GeneralOAuthFlow") driver.type("#identifierId", <Your Username Here>) driver.click("#identifierNext > div > button") driver.type("#password > div.aCsJod.oJeWuf > div > div.Xb9hP > input", <Password Here>) driver.click("#passwordNext > div > button") driver.save_screenshot("test.png")
This browser or app may not be secure.
Requesting to provide some sample synthetic jobs that handle sign in page functionality. Please do the needful
@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.
@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
Same here.
@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.
@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
Did you find any solution ?