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/tokenexchange.
On failure the Firebase error.message (e.g.
EMAIL_NOT_FOUND,INVALID_LOGIN_CREDENTIALS,TOO_MANY_ATTEMPTS_TRY_LATER) is surfaced verbatim in the raisedAuthenticationErrorso 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
Noneto skip the post-login navigation entirely. Default isPOST_LOGIN_PATH.
- class gamesheet_sdk.common.auth.login.AdminLoginFlow[source]¶
Bases:
objectBrowser-based
LoginFlowfor the admin dashboard.Wraps the headless-browser
login()flow in a class that conforms to theLoginFlowprotocol. 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
Authenticating with the admin dashboard:
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"])
- Parameters:
config (Config) – SDK configuration (credentials, URLs, storage paths).
Initialize AdminLoginFlow with SDK config.
- Parameters:
config (Config) – SDK configuration (credentials, URLs, storage paths).
- __init__(config)[source]¶
Initialize AdminLoginFlow with SDK config.
- 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 vialogin(), and reads the persisted tokens from the saved browser state file.- Parameters:
- Returns:
dict[str, str] – Token bundle with
"access"and"refresh"keys.- Raises:
AuthenticationError – If credentials are missing, the auth backend rejects them, or tokens are not found in the saved state after login.
- Return type: