Authentication API
Manage user authentication, password resets, wallet sign-in, Farcaster identity, and token gating.Auth middleware
Protected backend endpoints require a valid JWT in theAuthorization header. The middleware verifies the token, attaches user context to the request, and sets the row-level security (RLS) context on the database connection before any query runs.
Request format
JWT payload
Tokens expire after 7 days.
Error responses
After successful authentication, the middleware sets the database-level user context for RLS. All subsequent queries in that request are automatically scoped to the authenticated user’s data. See Security for details.
Sign up
Request body
Response
Errors
Sign in
Request body
OAuth sign in
OAuth providers support automatic account linking. If a user with the same email address already exists, the OAuth account is linked to the existing user on first sign-in. This lets users who originally signed up with email and password add GitHub or Google login without creating a duplicate account.GitHub
GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET to be configured.
GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET to be configured.
Wallet sign in (SIWE)
How it works
- The client opens the Base Account SDK popup and requests a SIWE signature on Base Mainnet (chain ID
0x2105). - The signed SIWE message and signature are sent to the
walletNextAuth credentials provider. - The server parses the SIWE message, validates the domain, and verifies the signature.
- If no account exists for the wallet address, a new user is created automatically.
- If an account with the same email already exists (from a previous OAuth or email sign-up), the wallet is linked to the existing account.
Request body
Response
On success, a session cookie is set and the user is redirected to the callback URL. The response follows the standard NextAuth credentials callback flow.Account linking
When a wallet signs in, the system checks for an existing user by the wallet-derived email address. If a matching user is found (for example, one who previously signed up with email and password or OAuth), the wallet provider is linked to that existing account. This prevents duplicate accounts and lets users access the same data regardless of which sign-in method they use.Errors
The SIWE domain is validated against the configured application URL to prevent replay attacks from other sites.
Get current user
Response
Errors
Update profile
You can update your profile using eitherPOST or PATCH.
Request body (POST)
Errors (POST)
Request body (PATCH)
Change password
Request body
Response
Errors
Forgot password
Request body
Response
Errors
Reset password
Request body
Response
Errors
Farcaster authentication
Verify Farcaster identity
GET method returns endpoint metadata. The POST method verifies a Farcaster ID token and optionally checks $RAVE token gating on Base.
Request body
Response
Errors
Refresh Farcaster token
GET method returns endpoint metadata.
Request body
Response
Errors
Token gating
Verify token access (POST)
$RAVE tokens on Base mainnet.