Skip to main content

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 the Authorization 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

Protected by bot detection. Automated or non-browser requests may be rejected.

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

Redirects to GitHub OAuth flow. Requires GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET to be configured.

Google

Redirects to Google OAuth flow. Requires GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET to be configured.

Wallet sign in (SIWE)

Sign in using an Ethereum wallet via Sign-In with Ethereum (SIWE). This flow is designed for Base smart wallets and supports ERC-6492 signature verification for pre-deployed wallets.

How it works

  1. The client opens the Base Account SDK popup and requests a SIWE signature on Base Mainnet (chain ID 0x2105).
  2. The signed SIWE message and signature are sent to the wallet NextAuth credentials provider.
  3. The server parses the SIWE message, validates the domain, and verifies the signature.
  4. If no account exists for the wallet address, a new user is created automatically.
  5. 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

Requires session authentication. Returns the current user profile.

Response

Errors

Update profile

You can update your profile using either POST or PATCH.

Request body (POST)

Errors (POST)

Request body (PATCH)

Change password

Request body

Response

Errors

Forgot password

Protected by bot detection. Rate-limited per IP address. Always returns the same response regardless of whether the email exists, to prevent user enumeration.

Request body

Response

Errors

Reset password

Rate-limited per IP address.

Request body

Response

Errors

Farcaster authentication

Verify Farcaster identity

The 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

The GET method returns endpoint metadata.

Request body

Response

Errors

Token gating

Verify token access (POST)

Checks whether a wallet holds sufficient $RAVE tokens on Base mainnet.

Request body

Response

Errors

Verify token access (GET)

Query parameters

Response

Webhook events