Deploy Your App uses session-based authentication powered byDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/nayalsaurav/deploy-your-app/llms.txt
Use this file to discover all available pages before exploring further.
better-auth with GitHub as the sole OAuth provider. Every /api/v1/ endpoint calls getSession() internally and returns a 401 Unauthorized response immediately if no valid session is found — there is no public or unauthenticated surface in the API.
How Authentication Works
The full OAuth flow, from browser click to authenticated API access, proceeds as follows:- The user opens the web dashboard and clicks Sign in with GitHub.
- The browser is redirected to GitHub’s authorization page, where the user grants the requested OAuth scopes (
read:user,user:email,repo,write:repo_hook). - GitHub redirects back to
{NEXT_PUBLIC_APP_URL}/api/auth/callback/githubwith a temporary authorization code. - The
better-authlibrary exchanges the code for an access token, creates a user session in PostgreSQL via Prisma, and sets an HTTP-only session cookie on the response. - Every subsequent request to
/api/v1/includes that cookie automatically, and the server validates it on each call viaauth.api.getSession().
/api/auth/[...all] proxies all better-auth requests — including sign-in, sign-out, and session retrieval — to the better-auth core handler using toNextJsHandler(auth).
Using the API from a Browser
When you are signed in through the dashboard, authentication is fully transparent:- The session cookie is set automatically by
better-authafter the OAuth callback. - The
authClient(created withcreateAuthClient) is configured withbaseURL: NEXT_PUBLIC_APP_URL, so all client-side requests target the correct origin. - Fetch calls made from dashboard components automatically include the session cookie because they share the same origin.
Using the API Programmatically
There is no dedicated API key mechanism. To call the API from a script or tool likecurl, you must first complete the OAuth flow in a real browser to obtain a live session token, then export that token for use in your requests.
Step 1 — Sign in via the browser
Navigate to your Deploy Your App dashboard and complete the GitHub OAuth login.
Step 2 — Copy the session token
Open your browser’s DevTools → Application → Cookies and locate the cookie named better-auth.session_token. Copy its value.
Step 3 — Pass the cookie with your requests
Auth Session Endpoint
You can verify your current session at any time by calling thebetter-auth session endpoint, which is proxied through the Next.js route handler at /api/auth/[...all]:
null.
GitHub OAuth App Setup
To enable authentication on a self-hosted instance, you must register a GitHub OAuth App and supply its credentials as environment variables.See the Self-Hosting guide for the full list of required environment variables, including
BETTER_AUTH_SECRET, GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET, and NEXT_PUBLIC_APP_URL.- Go to GitHub → Settings → Developer settings → OAuth Apps → New OAuth App.
- Fill in the application name (e.g.
Deploy Your App). - Set Homepage URL to your instance URL:
- Set Authorization callback URL to the
better-authcallback path: - Click Register application and copy the Client ID and Client Secret into your environment:
read:user, user:email, repo, and write:repo_hook. The repo and write:repo_hook scopes are required so Deploy Your App can list repositories and automatically register push-event webhooks when you import a project.