Space tokens
- class atproto_space.tokens.SpaceToken(iss: str, sub: str, exp: float, jti: str, iat: float | None = None, aud: str | None = None, key_id: str | None = None)
Bases:
objectClaims of a delegation token, a space credential or a client attestation.
- iat
Time of issue as a Unix timestamp. A space credential always has it.
- Type:
float | None
- aud
Audience. A space credential has none.
- Type:
str | None
- key_id
DID key that a space credential is bound to.
- Type:
str | None
- atproto_space.tokens.get_space_host_audience(space_did: str) str
Get the audience that names the host of a space in delegation tokens and client attestations.
- Parameters:
space_did – DID of the space authority.
- Returns:
Audience.
- Return type:
- atproto_space.tokens.parse_space_token(kind: Literal['delegation', 'credential', 'client_attestation'], token: str) SpaceToken
Parse a space token and check its structure.
Note
The signature and the expiration are not verified.
- Parameters:
kind –
'delegation','credential'or'client_attestation'.token – JWT in the compact serialization.
- Returns:
Claims of the token.
- Return type:
- Raises:
atproto_space.exceptions.SpaceTokenError – The token is not a well-formed token of this kind.
- atproto_space.tokens.create_client_attestation(client_id: str, audience: str, private_key: EllipticCurvePrivateKey, kid: str | None = None, expires_in: int = 60) str
Create a proof of the identity of an OAuth client for the host of a space.
- Parameters:
client_id – Client ID of the OAuth client.
audience – Audience that names the host of the space. See
get_space_host_audience().private_key – P-256 private key from the JWKS of the client.
kid – ID of the key in the JWKS of the client.
expires_in – Lifetime of the attestation in seconds.
- Returns:
Client attestation, a JWT in the compact serialization.
- Return type:
- Raises:
atproto_crypto.exceptions.UnsupportedKeyTypeError – The private key is not a P-256 key.