How it works
Log in
Call
POST /api/auth/login with your email and password. The response includes an accessToken and sets an httpOnly refreshToken cookie.Send authenticated requests
Include the access token in the
Authorization header as Bearer <accessToken>.Token lifetimes
| Token | Lifetime | Transport |
|---|---|---|
| Access token | 2 hours | Response body |
| Refresh token | 7 days | HttpOnly cookie |
Logging in
POST /api/auth/login
Authenticates a user with email and password. Returns an access token in the response body and sets arefreshToken httpOnly cookie.
Request body
The user’s email address.
The user’s password.
Human-readable result message.
JWT access token. Include this in the
Authorization header for subsequent requests.The authenticated user’s role:
client, freelancer, or admin.Making authenticated requests
Pass the access token in theAuthorization header using the Bearer scheme.
refreshToken cookie is sent automatically with same-origin requests.
Refreshing an access token
POST /api/auth/refresh-token
Issues a new access token using therefreshToken cookie. No request body is needed — the cookie is read automatically.
401 with the message "Invalid token" or "Token is required".
Google OAuth login
POST /api/auth/google-login
Authenticates a user with a Google credential token. If no Skillhouse account exists for the Google email, a new account is created automatically.The credential token returned by the Google Identity Services SDK after the user completes the Google sign-in flow.
The role to assign if a new account is created:
client or freelancer. Ignored for existing accounts.accessToken and the user object, and the refreshToken cookie is set.
Role-based access
After authentication, each request is checked against the role encoded in the JWT. Some endpoints are restricted to specific roles.| Role | Access |
|---|---|
client | Client job posting, contracts, and payment endpoints |
freelancer | Freelancer application, contract, and wallet endpoints |
admin | Admin user management, category, escrow, and revenue endpoints |
Error responses
401 Unauthorized
Returned when the token is missing, expired, or invalid. Re-authenticate by calling/api/auth/login or refresh your access token with /api/auth/refresh-token.
403 Forbidden
Returned when your token is valid but your role does not have permission to access the endpoint.403 can also be returned if your account has been blocked by an admin. In that case, re-authenticating will not resolve the error.
Logging out
POST /api/auth/logout
Clears therefreshToken cookie. After logging out, the access token you hold remains valid until it expires (up to 2 hours). Discard it client-side immediately.
Related pages
Auth endpoints
Full reference for all
/api/auth/* routes including registration and password reset.Authentication feature
Overview of how authentication works across the Skillhouse platform.
