Overview
TripLoom uses Supabase JWT tokens for API authentication. All requests to/v1 endpoints must include a valid JWT token in the Authorization header.
Authentication flow
- User authenticates through Supabase client SDK
- Supabase returns a JWT token
- Client includes token in API requests
- TripLoom API validates token using Supabase JWKS
Making authenticated requests
Include the JWT token in theAuthorization header using the Bearer scheme:
The
Authorization header is case-insensitive for the Bearer prefix, but the token itself is case-sensitive.Token validation
The authentication middleware validates tokens by:- Extracting the token from the
Authorizationheader:
- Verifying the signature using Supabase JWKS:
- Validating claims including issuer and subject:
- Extracting user ID from the
subclaim and storing it in request context:
Authentication errors
The API returns401 Unauthorized with specific error messages:
| Error | Description |
|---|---|
missing bearer token | Authorization header is missing or doesn’t use Bearer scheme |
invalid token | Token signature is invalid or token is expired |
invalid claims | Token claims cannot be parsed |
invalid issuer | Token issuer doesn’t match Supabase URL |
missing subject | Token is missing the sub claim (user ID) |
Token claims
Supabase JWT tokens include standard claims:iss(issuer): Supabase project URLsub(subject): User ID (UUID)aud(audience):authenticatedexp(expiration): Token expiration timestampiat(issued at): Token creation timestamp
sub claim and makes it available to all authenticated endpoints.
Development mode
In development environments where Supabase is not configured, the API uses test user passthrough mode:Test user mode is only available in development. Production environments always require valid Supabase JWT tokens.