Log in to the HTTP backend#

Goal#

Authenticate against a PlayMolecule HTTP backend so app calls submit jobs through the backend instead of running locally.

Minimal example#

playmolecule login --email you@example.com

You’ll be prompted for a password (or read it from PM_PASSWORD / PLAYMOLECULE_PASSWORD). On success, a cookie is written to ~/.cache/playmolecule/cookies/ and reused by every subsequent call.

From Python#

from playmolecule import login, logout

login("you@example.com", "•••••••")
# ... use playmolecule normally ...
logout()

login() raises if PM_EXECUTOR (or PM_REGISTRIES for an http:// registry) doesn’t point at a valid HTTP URL.

Configure where to log in#

The HTTP URL comes from your environment:

export PM_REGISTRIES=http://playmolecule.example.com
export PM_EXECUTOR=http://playmolecule.example.com    # often the same URL

PM_REGISTRIES tells PlayMolecule where to fetch manifests; PM_EXECUTOR tells it where to submit jobs. They’re independent — you can browse an HTTP registry but execute locally, or vice versa.

Non-interactive login (CI)#

export PLAYMOLECULE_EMAIL=ci@example.com
export PLAYMOLECULE_PASSWORD='••••••••••'
playmolecule login

Or the PM_* aliases:

export PM_EMAIL=ci@example.com
export PM_PASSWORD='••••••••••'
playmolecule login

Log out#

playmolecule logout

Clears the session cookie locally. Equivalent in Python:

from playmolecule import logout
logout()

Gotchas#

  • The backend issues a CSRF token before accepting credentials; if the first request fails with an HTTP error, the URL is almost certainly wrong or the backend isn’t reachable.

  • A logged-in session is persisted per host. Different machines need their own login.

  • login doesn’t validate the credentials beyond what the server reports — if you mistyped the password you’ll see the failure surface as an HTTP 401 from the next API call, not the login itself.

See also#