Authentication Guide
LangMart supports multiple authentication methods to suit different use cases. This guide covers all the ways you can authenticate with the platform.
Authentication Overview
| Method | Best For | Session Duration |
|---|---|---|
| OAuth (Google/GitHub) | Regular users, teams | Persistent (30 days) |
| API Key | Programmatic access | Until revoked |
| Guest Access | Trying the platform | Session-based |
OAuth Login
OAuth is the recommended authentication method for web users. It provides a seamless login experience without managing passwords.
Supported Providers
| Provider | Features |
|---|---|
| Fast signup, profile sync, trusted | |
| GitHub | Developer-friendly, org sync |
How OAuth Works
- Initiate Login - Click "Sign in with Google" or "Sign in with GitHub" on the login page
- Authorize - You're redirected to the provider to grant LangMart access
- Callback - After authorization, you're redirected back to LangMart
- Session Created - A session is established with your user account
OAuth Flow Diagram
┌──────────┐ ┌──────────────┐ ┌────────────┐
│ User │────>│ LangMart │────>│ Provider │
│ Browser │ │ Web App │ │ (Google/ │
│ │ │ │ │ GitHub) │
└──────────┘ └──────────────┘ └────────────┘
│ │ │
│ 1. Click Login │ │
│─────────────────>│ │
│ │ 2. Redirect │
│ │───────────────────>│
│ │ │
│<─────────────────────────────────────│
│ 3. User authorizes │
│ │ │
│ │<───────────────────│
│ │ 4. OAuth token │
│<─────────────────│ │
│ 5. Session established │First-Time OAuth Users
When you log in with OAuth for the first time:
- A new user account is created using your OAuth profile
- You're assigned to a default organization
- An API key is automatically generated for your session
- Your display name and avatar are synced from your OAuth provider
Linking Multiple OAuth Providers
Currently, each OAuth provider creates a separate account. If you need to access the same account from multiple providers, contact support.
Email Registration
For users who prefer traditional email-based authentication:
Registration
- Navigate to the Register option on the login page
- Enter your email address and create a password
- Verify your email through the confirmation link
- Log in with your credentials
Password Requirements
- Minimum 8 characters
- At least one uppercase letter
- At least one lowercase letter
- At least one number
Password Reset
- Click "Forgot Password" on the login page
- Enter your email address
- Check your email for a reset link
- Create a new password
Guest Access
Guest access lets you explore LangMart without creating an account.
Starting a Guest Session
- Visit https://langmart.ai
- Click Continue as Guest
- A temporary session is created automatically
Guest Limitations
| Feature | Guest | Registered |
|---|---|---|
| Chat with models | Limited | Full access |
| View models | Yes | Yes |
| Create connections | No | Yes |
| API key access | Temporary | Permanent |
| Save preferences | No | Yes |
| Organization access | No | Yes |
| Usage history | Session only | Persistent |
Converting Guest to Account
To convert your guest session to a full account:
- Click Sign Up in the top navigation
- Choose OAuth or email registration
- Your guest session will be migrated to your new account
Note: Guest session data is not automatically preserved. Create an account before doing important work.
JWT Tokens
LangMart uses JSON Web Tokens (JWT) for session management.
Token Structure
Header.Payload.SignatureToken Lifecycle
| Event | Action |
|---|---|
| Login | Access token + refresh token issued |
| API Request | Access token sent in Authorization header |
| Token Expiry | Refresh token used to get new access token |
| Logout | Both tokens invalidated |
Token Expiration
| Token Type | Duration | Notes |
|---|---|---|
| Access Token | 1 hour | Short-lived for security |
| Refresh Token | 30 days | Used to get new access tokens |
| Session Cookie | 30 days | Maintains browser session |
Automatic Token Refresh
The web application automatically refreshes tokens:
- When a request fails with 401 Unauthorized
- Proactively before token expiration
- On page reload (validates stored session)
Manual Token Refresh
For API clients, you can refresh tokens manually:
curl -X POST https://api.langmart.ai/v1/auth/refresh \
-H "Content-Type: application/json" \
-d '{
"refresh_token": "YOUR_REFRESH_TOKEN"
}'API Key Authentication
API keys provide programmatic access to the LangMart API.
Creating API Keys
- Go to Settings > API Keys
- Click Create New Key
- Enter a descriptive name
- Copy the key immediately (shown only once)
API Key Format
sk-langmart-xxxxxxxxxxxxxxxxxxxxxxxx- Prefix:
sk-langmart- - Random characters: 24+ alphanumeric characters
Using API Keys
Include your API key in the Authorization header:
curl -X GET https://api.langmart.ai/v1/models \
-H "Authorization: Bearer sk-langmart-your-key-here"API Key Scopes
Currently, all API keys have full access to your account. Fine-grained permissions are planned for a future release.
Key Management Best Practices
| Practice | Description |
|---|---|
| Descriptive Names | Name keys by purpose (e.g., "Production Server", "Local Dev") |
| Regular Rotation | Rotate keys periodically for security |
| Environment Variables | Store keys in env vars, not code |
| Separate Keys | Use different keys for dev/staging/production |
| Revoke Unused | Delete keys that are no longer needed |
Revoking API Keys
To revoke an API key:
- Go to Settings > API Keys
- Find the key you want to revoke
- Click the Delete button
- Confirm the deletion
Warning: Revoking a key immediately invalidates it. Any applications using that key will stop working.
Security Best Practices
Do
- Use OAuth for web applications when possible
- Store API keys in environment variables
- Rotate API keys periodically
- Use HTTPS for all API calls
- Log out of shared computers
Don't
- Share API keys in public repositories
- Hardcode API keys in source code
- Share API keys in chat or email
- Use the same API key for multiple environments
- Ignore security alerts from LangMart
Session Management
Viewing Active Sessions
- Go to Settings > Security
- View all active sessions with device/location info
- Revoke suspicious sessions if needed
Logging Out
To log out:
- Click your profile icon in the top navigation
- Select Logout
- Your session is invalidated immediately
Logging Out Everywhere
To log out from all devices:
- Go to Settings > Security
- Click Log Out All Sessions
- All active sessions are invalidated
Troubleshooting Authentication
"Invalid credentials" Error
- Verify your email and password
- Check for caps lock
- Try resetting your password
OAuth Redirect Issues
- Clear browser cookies and try again
- Disable browser extensions that may block redirects
- Try a different browser
API Key Not Working
- Verify the key was copied completely
- Check that the key hasn't been revoked
- Ensure you're using
Bearertoken format
Session Expired
- Refresh the page to trigger automatic token refresh
- If that fails, log in again
- Check that your browser accepts cookies
API Endpoints Reference
| Endpoint | Method | Description |
|---|---|---|
/v1/auth/login |
POST | Email/password login |
/v1/auth/register |
POST | Create new account |
/v1/auth/logout |
POST | End current session |
/v1/auth/refresh |
POST | Refresh access token |
/v1/auth/guest |
POST | Create guest session |
/v1/auth/validate |
GET | Validate current token |
/v1/auth/authorize |
GET | Start OAuth flow |
/v1/auth/callback |
GET | OAuth callback handler |