Session

User sessions: a short-lived token for one user, safe to hand to a browser.

session = user.session(scopes=["agents", "humans"], ttl_s=3600)
token = session.token                       # your frontend uses it as its API key

client = noclick.Client.for_session(session)     # or act as that user from Python
class Session

A token pinned to one user with a subset of the minting key's scopes. Its repr never shows the token.

Attributes
tokenstr
idstr | None
user_idstr | None
scopeslist[str]
expires_atAny
rawdict[str, Any]

The response JSON exactly as the API sent it.

base_urlstr | None
expiredbool

Whether expires_at has passed (by this machine's clock).

client

session.client(**kwargs) -> Any

A client that acts as this session: noclick.Agent.list(client=session.client()).

Parameters
**kwargsAny
Returns
Any

A client holding the session's token, pointed at the API the session came from. Every call it makes acts as the session's user, with the session's scopes.

Usage
user = noclick.User.from_id("user_42")
session = user.session(["agents"], ttl_s=600)
as_ana = session.client()
noclick.Agent.list(client=as_ana)   # Ana's agents and the shared ones, nothing else