Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Selenium WebDriver for Auth #65

Closed
initstring opened this issue Sep 2, 2023 · 1 comment · Fixed by #66
Closed

Implement Selenium WebDriver for Auth #65

initstring opened this issue Sep 2, 2023 · 1 comment · Fixed by #66
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@initstring
Copy link
Owner

initstring commented Sep 2, 2023

Maintaining the login function is a cat/mouse game. Having Selenium launch a browser, allowing the user to login there, and then closing it to get the cookies would reduce a lot of pain and troubleshooting.

This would solve most issues that get opened, and also support 2FA.

The existing login() function could be reduced to something like this:

def login():
    """Creates a new authenticated session.

    This now uses Selenium because I got very tired playing cat/mouse
    with LinkedIn's login process.
    """
    driver = webdriver.Firefox()
    driver.get("https://linkedin.com/login")

    # Pause until the user lets us know the session is good.
    input("Press Enter after you've logged in...")
    selenium_cookies = driver.get_cookies()
    driver.quit()

    # Initialize and return a requests session
    session = requests.Session()
    for cookie in selenium_cookies:
        session.cookies.set(cookie['name'], cookie['value'])

    return session

I'd also need to remove the username and password args.

I tried to test this just now, but ran into issues with Selenium and my Linux VM - probably either because it was Ubuntu using snaps as browsers, or because it was ARM64.

I can try to come back and test this later, but I am very open to help if someone else wants to give it a try.

@initstring initstring added enhancement New feature or request help wanted Extra attention is needed labels Sep 2, 2023
@initstring initstring linked a pull request Sep 3, 2023 that will close this issue
@initstring
Copy link
Owner Author

This is working in #66.

Tested on MacOS ARM64, should also work in Windows x86/64, Windows ARM64, and Linux x86/64. I understand Selenium is not fully working on Linux ARM64, which may be an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant