Skip to content

Server Types

Returned by create_user(), login(), refresh(), verify_magic_link(), and verify_email_otp().

{
    "user": UserResponse,
    "tokens": AuthTokens,
}
{
    "user": UserResponse,
    "tokens": AuthTokens,
}
FieldTypeDescription
userUserResponseUser info
tokensAuthTokensToken pair

User information. Returned inside AuthResponse and from the current_user dependency.

{
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "email": "user@example.com",
    "name": "Jane Doe",
    "email_verified": false,
    "avatar_url": null,
    "phone": null,
    "banned": false,
    "roles": ["admin"],
    "created_at": "2026-01-15T10:30:00Z",
    "session_id": "660f9500-f30c-52e5-b827-557766550000"
}
{
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "email": "user@example.com",
    "name": "Jane Doe",
    "email_verified": false,
    "avatar_url": null,
    "phone": null,
    "banned": false,
    "roles": ["admin"],
    "created_at": "2026-01-15T10:30:00Z",
    "session_id": "660f9500-f30c-52e5-b827-557766550000"
}
FieldTypeDescription
idUUIDUser UUID
emailstrEmail address
namestr | NoneDisplay name
email_verifiedboolWhether email is verified
avatar_urlstr | NoneProfile image URL (from OAuth)
phonestr | NonePhone number
bannedboolWhether the user is banned
roleslist[str]Assigned roles
created_atdatetimeAccount creation time
session_idUUID | NoneCurrent session ID (from sid JWT claim)

Token pair returned inside AuthResponse.

FieldTypeDescription
access_tokenstrJWT access token
refresh_tokenstrOpaque refresh token
expires_inintAccess token TTL in seconds

Returned by get_sessions().

FieldTypeDescription
idUUIDSession UUID
user_agentstr | NoneBrowser/client identifier at login
ip_addressstr | NoneClient IP at login
created_atdatetimeSession creation time
expires_atdatetimeSession expiration time
revokedboolWhether the session is revoked

Returned by list_users().

FieldTypeDescription
userslist[UserResponse]Users on the current page
totalintTotal matching users across all pages
limitintPage size used
offsetintOffset used

Event payload for user_deleted.

FieldTypeDescription
user_idUUIDDeleted user’s ID
emailstrDeleted user’s email
timestampdatetimeWhen the deletion occurred

Exception raised by all AuthFort methods on failure.

from authfort import AuthError

try:
    await auth.login("user@example.com", "wrong")
except AuthError as e:
    print(e.message)      # "Invalid credentials"
    print(e.code)         # "invalid_credentials"
    print(e.status_code)  # 401
from authfort import AuthError

try:
    await auth.login("user@example.com", "wrong")
except AuthError as e:
    print(e.message)      # "Invalid credentials"
    print(e.code)         # "invalid_credentials"
    print(e.status_code)  # 401
FieldTypeDescription
messagestrHuman-readable error message
codestrMachine-readable error code
status_codeintHTTP status code
CodeStatusMeaning
invalid_credentials401Wrong email or password
user_exists409Email already registered
oauth_account400Account uses social login
user_banned403Account is banned
signup_disabled403Public signup is disabled
refresh_token_invalid401Refresh token invalid
refresh_token_expired401Refresh token expired
user_not_found404User not found
invalid_password400Old password incorrect (change password)
invalid_reset_token400Reset token invalid or expired
oauth_state_invalid400Invalid OAuth state
oauth_state_expired400OAuth state expired
invalid_email400Invalid email address
invalid_verification_token400Email verification token invalid or expired
invalid_magic_link400Magic link token invalid or expired
invalid_otp400OTP code invalid or expired
oauth_no_email400OAuth provider did not return an email
oauth_no_user_id400OAuth provider did not return a user ID