tdameritrade
tdameritrade copied to clipboard
headless chromedriver?
Out of curiosity, is there a way to have the authentication method run entirely headless if username and password parameters are passed so that it can be used on things such as servers and google colab without modification? I have currently modified the auth/init.py to include the following:
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
chrome_driver_binary = which('chromedriver') or "/usr/lib/chromium-browser/chromedriver"
driver = webdriver.Chrome('chromedriver', options=options)
however I don't know if this would work on other operating systems and implementations.
@anishzute Im not certain about how the --headless
flag is handled on every OS but it seems at least on OSX and Ubuntu It has worked for me. Also I have a PR open that handles automating the entire Auth flow. It will default to a headless selenium instance. See code
Nice! I'm currently working on Ubuntu off a forked repo where I've incorporated the headless flag, but it's always a pain to deal with local chromedriver and all that, especially because I tend to do a lot of my quick scripting/prototyping in Google Colab/Jupyter. I'm hoping your auth method gets merged as it seems much more straightforward and it would be nice to have 2 factor support. Regardless, I'll copy over your code and give it a go. Thanks!
I went ahead and merged into dev branch.
We don't have tests running on that yet. @timkpaine can we update the azure-pipeline.yml to trigger on dev also? Not sure what 2nd order effects that would have.
yep just add it to the list of triggers in the pipelines file