Managing Website Authentication
Username and Password
For sites that lack two factor-authentication, the best way to manage login is by entering a username and password using a combination of Simplex’s type, click, press_tab, and press_enter actions.
This prevents needing to manage cookies or other login tokens that often expire after one-time use or need to be refreshed.
Saving Session Data
We provide the capture_login_session method to save a login session to a JSON file. This function returns a JSON containing the cookies and localStorage of the browser after being logged in.
You should see the following output:
Two-Factor Authentication (2FA)
There are two ways to handle 2FA:
- Store your 2FA cookies in a session JSON using capture_login_session, then load the session JSON using Simplex’s create_session function.
2FA 'save cookies' option in the browser.
If you see a checkbox like the above in red when you login with 2FA, you can often check it then use the session JSON saved from that session to login directly.
When using this method, sometimes only the 2FA cookies are saved (and not the username/password cookies), and you’ll need to use Simplex’s actions to login with a username and password, then have the session cookies bypass the 2FA check.
- Disable 2FA for the site.
If you’re able to disable 2FA for the site, you can often just login with your username and password. This is the safest option, but it’s not always possible and is of course less secure.
Restoring Login Sessions
Login sessions can be restored using the session_data
parameter in the constructor.
We show an example below. Let’s say you have a login session JSON for Coupa.com stored at sessions/coupa_login_session.json
.
Sample Usage
Alternative ways to save session data
CLI tool
We provide a CLI tool to create login sessions. You can create a login session using simplex login [site]
after installing the Simplex Python SDK.
After you log in, you can click the button on the page to capture the login session. This will download a JSON containing your session data to wherever you ran the command from.
If you’d instead like to use the SDK, you can use the capture_login_session
method.