gamesheet_sdk.common.auth.flow module¶
Login flow protocol for pluggable authentication strategies.
Defines LoginFlow, the structural interface that both admin
(browser-based) and teams (HTTP-only) authentication implement.
Downstream code that needs to authenticate — CLI commands, session
construction helpers — depends on this protocol rather than on a
concrete login function, so the auth mechanism can vary per pillar
without changing the consumer.
Example — using a LoginFlow implementation:
from gamesheet_sdk.common.auth.flow import LoginFlow
from gamesheet_sdk.common.auth.tokens import save_tokens
from gamesheet_sdk.common.config import Config
def run_login(flow: LoginFlow, config: Config) -> None:
tokens = flow.authenticate(email="user@example.com")
save_tokens(config, **tokens)
- class gamesheet_sdk.common.auth.flow.LoginFlow[source]¶
Bases:
ProtocolStructural interface for authentication flows.
Any class that exposes an
authenticatemethod with the signature below is a validLoginFlow— no explicit inheritance needed (structural subtyping viatyping.Protocol).Implementations hold whatever state they need (a
Config, aBrowserSession, HTTP clients, etc.) and expose only the commonauthenticateentry point.The returned dict contains at minimum
"access"and"refresh"keys. Admin flows may also include"roles". The shape matchesrefresh_access_token()’s return value and can be unpacked directly intosave_tokens().- authenticate(email=None, password=None, *, timeout=None)[source]¶
Authenticate with the GameSheet platform and return tokens.
Credential resolution follows a standard fallback chain: explicit arguments →
GAMESHEET_USERNAME/GAMESHEET_PASSWORDenv vars →Configfields. Implementations raiseAuthenticationErrorwhen credentials are missing or authentication is rejected.- Parameters:
- Returns:
Token bundle with at least
"access"and"refresh"keys.- Return type:
- Raises:
AuthenticationError – If credentials are missing or the auth backend rejects them.
- __init__(*args, **kwargs)¶