Supported providers
GitHub
Authenticate using your GitHub account
Authenticate using your Google account
OAuth flow
Initiate login
Run the login command:Or specify a provider explicitly:The CLI:
- Generates a random state parameter for CSRF protection (32-byte base64-encoded string)
- Starts a local HTTP server on
127.0.0.1:9876to receive the OAuth callback - Opens your browser to the OAuth provider’s login page
cmd/cli/main.go:84-157:Complete OAuth flow
In your browser:The server-side OAuth implementation from
- You’re redirected to the OAuth provider (GitHub or Google)
- Grant permission to Prompts.dev
- The provider redirects back to the Prompts.dev API
The API validates the state parameter to prevent CSRF attacks using HMAC-SHA256 signatures.
internal/auth/service.go:155-262:GitHub OAuth:- Scopes requested:
read:user,user:email - Fetches user profile from
https://api.github.com/user - Retrieves verified email from
https://api.github.com/user/emails
- Scopes requested:
openid,email,profile - Fetches user profile from
https://openidconnect.googleapis.com/v1/userinfo
User creation and identity linking
The authentication service performs the following:
- Checks if a user identity exists for the provider user ID
- If not found, checks if a user exists with the verified email
- Creates a new user if needed
- Links the OAuth identity to the user account
internal/auth/service.go:88-128:JWT token issuance
After successful authentication:JWT claims include:
- The API generates a JWT token containing your user ID
- For CLI flows, redirects to
http://localhost:9876/callback?token=<jwt>&state=<state> - The local CLI server captures the token
internal/auth/token.go:15-27:user_id: Your unique user identifiersub: Subject (same as user_id)iat: Issued at timestampexp: Expiration timestamp
Using the token
The CLI automatically reads the token from~/.prompts/config.json and includes it in API requests.
From pkg/client/client.go:32-40:
Token expiration
JWT tokens expire after a configured number of hours (typically 720 hours / 30 days). When a token expires:- API requests return a
401 Unauthorizedstatus - The CLI returns an
ErrUnauthenticatederror - You need to run
prompt loginagain to obtain a new token
pkg/client/client.go:70-78:
Security considerations
State parameter
Random 32-byte state prevents CSRF attacks using HMAC signatures
Local server
Binds to 127.0.0.1 (localhost only) to prevent remote access
Token storage
Stored with 0600 permissions (owner read/write only)
Timeout
Login flow times out after 2 minutes if not completed
Environment variables
Customize authentication behavior:Troubleshooting
Login fails silently
Check if port 9876 is available:Token not found
Verify the token file exists:prompt login again.
Unauthenticated errors
Your token may have expired. Re-authenticate:State mismatch
This indicates a potential CSRF attack or browser cookie issues. Clear your browser cookies and try again:Manual token management
You can manually set a token if needed:Next steps
Quickstart
Get started with your first prompt
CLI reference
Explore all available commands