TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/exegia/corpora-py/llms.txt
Use this file to discover all available pages before exploring further.
exegia.auth module provides high-level authentication functions that wrap Supabase Auth and enforce the public.users profile check. Authentication (establishing an identity) and sign-up (provisioning the application profile row) are deliberately separate steps. All functions return typed frozen dataclasses so callers can branch on structured outcomes rather than catching exceptions for expected states.
Dataclasses
SignInResult
ok is True, the user is fully authenticated and has a public.users record.
True when the user is authenticated and has a public.users profile record.Combined auth identity and profile. Set only when
ok is True.Supabase session containing the access and refresh tokens. Present whenever the provider authenticated the user — including the
needs_signup path — so the caller can pass the token to sign_up().User-facing message. Set on non-
ok paths.True when the provider authenticated the user but no public.users record exists yet. The caller should offer registration.SignUpResult
sign_up().
True when a new public.users record was created for the user.The combined auth and profile payload. Set on success and also on the
already_registered path (the existing record is returned).The session when sign-up started one (anonymous flow).
User-facing message. Set on non-
ok paths.True when the user already had a public.users record. No new row was created.CurrentUser
public.users record.
The authenticated user from Supabase Auth (
auth.users).The matching
public.users record as a plain dict, or None when no application row exists yet (e.g. a freshly created anonymous user).The auth user’s UUID. Also the
public.users primary key.The user’s email address, if one is attached to the auth identity.
True when this is an anonymous (not-yet-linked) user.True when the user has been upgraded past the anonymous stage.True when a public.users record was found for this user.Identity providers linked to this user (e.g.
["google"]).True if provider is already linked to this user.
Sign-in functions
sign_in_with_id_token
public.users record. Produces a session in a single call.
The OIDC provider that issued the token. One of
"apple" or "google".The OIDC ID token (JWT) returned by the provider.
Optional provider access token.
Optional raw nonce used to obtain the ID token. Apple typically requires this.
Optional CAPTCHA verification token.
AuthApiError if the ID token is invalid or the provider is misconfigured.
request_email_otp
Destination email address.
Optional URL to redirect to after a magic-link click.
Whether to create a new auth user when the email is unknown. Defaults to the project setting when omitted.
Optional CAPTCHA verification token.
AuthOtpResponse — the OTP dispatch response.
Raises: AuthApiError if the code cannot be dispatched.
verify_email_otp
public.users profile check.
The email address the code was sent to.
The one-time code the user received.
Optional CAPTCHA verification token.
AuthApiError if the code is invalid or has expired.
Sign-up functions
sign_up
public.users record for a user. Provide access_token for a user who has already authenticated (via ID token or email OTP), or set anonymous=True to begin a fresh anonymous session and register that guest. Exactly one of the two is required.
If the user already has a public.users record, no new row is created and already_registered is set on the result.
JWT of an already-authenticated user to register.
Optional extra columns to set on the
public.users row (e.g. {"display_name": "Alice"}).When
True, starts an anonymous session first and registers that guest.Optional
user_metadata for the anonymous user. Used only when anonymous=True.Optional CAPTCHA token for the anonymous sign-in.
AuthApiError if anonymous sign-in fails or the access token is invalid. APIError if the profile insert fails unexpectedly.
start_anonymous_session
supabase.auth.sign_in_anonymously. Starts a guest session without creating a public.users record. Use this when you need an anonymous session independently of sign-up.
Optional metadata stored on the anonymous user’s
user_metadata.Optional CAPTCHA verification token.
AuthResponse with the new anonymous user and session.
Raises: AuthApiError if anonymous sign-ins are disabled for the project.
create_user_profile
public.users record for an auth user. Uses the service-role client so it bypasses RLS.
The
auth.users.id UUID to key the record by.Optional additional columns to set on the row, matching your
public.users schema.The created row as returned by the database insert.
APIError if the insert fails (e.g. a record already exists).
User resolution functions
get_current_user_record
public.users profile.
The user’s JWT (e.g. from the
Authorization header).A
CurrentUser combining the auth identity and profile row, or None when the token maps to no user.AuthApiError if the access token is invalid or expired.
get_profile
public.users row for a given auth UUID directly. Uses the service-role client and bypasses RLS.
The auth user UUID (
auth.users.id).The full
public.users row as a dict, or None when no matching record exists.link_identity_to_current_user
The current user’s JWT. Used to resolve the user and detect anonymous-upgrade scenarios.
The OAuth provider to link (e.g.
"apple" or "google").Optional URL to redirect to after the provider authorization completes.
Optional space-separated list of provider scopes to request.
Optional extra query parameters for the authorization URL.
ValueError if the access token maps to no current user. AuthApiError if linking is rejected by the auth server.