Sign In
Authentication
Sign In
Authenticate an existing user with email and password
POST
Sign In
Overview
This endpoint authenticates an existing user using their email and password with Supabase Authentication. Upon successful login, the user receives session tokens and is redirected to the homepage.Authentication
This endpoint does not require prior authentication (it creates the authentication session).
Rate Limiting
This endpoint is protected by rate limiting middleware:- Default limit: 100 requests per 60 seconds
- Returns
429 Too Many Requestswhen limit is exceeded - Prevents brute force attacks
Request Body
This endpoint acceptsapplication/x-www-form-urlencoded form data (typically from an HTML form submission).
User’s registered email address.Example:
user@example.comUser’s password.Example:
SecurePass123!Response
Upon successful authentication, this endpoint redirects to the homepage (
/) with a 302 Found status code.Redirect URL:
/Session cookies containing authentication tokens
Cookies Set
Upon successful sign-in, the following HTTP-only cookies are automatically set:
Attributes: HttpOnly, Secure, SameSite=Lax, Max-Age=7 daysContains the Supabase access token for authenticated requests
Attributes: HttpOnly, Secure, SameSite=Lax, Max-Age=7 daysContains the Supabase refresh token to maintain the session
Example Request
Success Response
Status Code:302 Found (Redirect)
Headers:
Error Responses
Missing Credentials
Status Code:400 Bad Request
Invalid Credentials
Status Code:401 Unauthorized
Account Not Found
Status Code:401 Unauthorized
Rate Limit Exceeded
Status Code:429 Too Many Requests
Number of seconds to wait before making another request
Server Error
Status Code:500 Internal Server Error
Security Features
Session Management
Once signed in:- Access Token: Valid for 1 hour by default
- Refresh Token: Valid for 7 days (matches cookie max-age)
- Auto-Refresh: The client should implement token refresh logic before expiration
- Cookie Expiry: Cookies expire after 7 days, requiring re-authentication
Handling Authentication State
Redirect Behavior
Default Redirect: After successful sign-in, users are redirected to
/ (homepage).To customize the redirect destination, you can:- Add a
redirectquery parameter to the form action - Modify the endpoint to accept a
returnToparameter - Store the intended destination in session storage before redirecting to sign-in
Form Integration Example
Related Endpoints
- Sign Up - Create a new user account
- Sign Out - End the current session
- Session - Check current authentication status
- Get Profile - Retrieve authenticated user’s profile
