gamesheet_sdk.common.auth.login module

Browser-based login flow against GameSheet’s Firebase Auth.

gamesheet_sdk.common.auth.login.login(session, email=None, password=None, *, timeout=None, post_login_path='/associations')[source]

Log into the GameSheet dashboard, leaving the session authenticated.

Success is determined by:

  • HTTP 200 from the Firebase signInWithPassword call, and

  • HTTP 200 from the subsequent /api/token exchange.

On failure the Firebase error.message (e.g. EMAIL_NOT_FOUND, INVALID_LOGIN_CREDENTIALS, TOO_MANY_ATTEMPTS_TRY_LATER) is surfaced verbatim in the raised AuthenticationError so callers know exactly what was wrong.

Parameters:
  • session (BrowserSession) – An open BrowserSession.

  • email (str | None) – Login email; falls back to session.config.username.

  • password (str | None) – Login password; falls back to session.config.password.get_secret_value().

  • timeout (float | None) – Seconds to wait for the auth backend round-trip (default 15).

  • post_login_path (str | None) – Path to navigate to after the auth round-trip succeeds. The SPA performs its real routing and post-login data fetches when it reaches this page, so the saved storage state afterwards captures a fully-settled session (cookies + any SPA-cached state) rather than just the bare auth cookie. Pass None to skip the post-login navigation entirely. Default is POST_LOGIN_PATH.

Raises:

AuthenticationError – If authentication fails (missing credentials, Firebase rejection, token exchange failure, or timeout).

class gamesheet_sdk.common.auth.login.AdminLoginFlow[source]

Bases: object

Browser-based LoginFlow for the admin dashboard.

Wraps the headless-browser login() flow in a class that conforms to the LoginFlow protocol. After the browser session closes (persisting localStorage to disk), the access and refresh tokens are read back and returned so callers can use them without touching the state file directly.

Example:

from gamesheet_sdk.common.auth.login import AdminLoginFlow
from gamesheet_sdk.common.config import Config

config = Config()
flow = AdminLoginFlow(config)
tokens = flow.authenticate(email="user@example.com")
print(tokens["access"])

Store the configuration for later browser-session creation.

Parameters:

config (Config) – SDK configuration (credentials, URLs, storage paths).

__init__(config)[source]

Store the configuration for later browser-session creation.

Parameters:

config (Config) – SDK configuration (credentials, URLs, storage paths).

authenticate(email=None, password=None, *, timeout=None)[source]

Run the browser-based admin login and return tokens.

Opens a BrowserSession, drives the Firebase login form via login(), and reads the persisted tokens from the saved browser state file.

Parameters:
  • email (str | None) – Login email, or None to resolve from config/env.

  • password (str | None) – Login password, or None to resolve from config/env.

  • timeout (float | None) – Auth round-trip timeout in seconds, or None for the default.

Returns:

Token bundle with "access" and "refresh" keys.

Return type:

dict[str, str]

Raises:

AuthenticationError – If credentials are missing, the auth backend rejects them, or tokens are not found in the saved state after login.