Exchange Token
Exchange a Supabase JWT token for a MentraOS core token.Endpoint
Request Body
Response
Success (200):Implementation
- File:
packages/cloud/src/routes/auth.routes.ts:19-51 - Verification: Uses
SUPABASE_JWT_SECRETenvironment variable - Token Generation: Signs with
AUGMENTOS_AUTH_JWT_SECRET - Token Expiry: No explicit expiry set on core token
Core Token Structure
The generated coreToken contains:sub: User ID from Supabaseemail: User’s email addressorganizations: Array of user’s organizationsdefaultOrg: User’s default organization
Generate Webview Token
Generate a temporary token for webview authentication within apps.Endpoint
Headers
Request Body
Response
Implementation
- File:
packages/cloud/src/routes/auth.routes.ts:54-69 - Middleware:
validateCoreToken- Validates the core JWT token - Service: Uses
tokenService.generateTemporaryToken()
Exchange User Token
Exchange a temporary token for user details (called by app backends).Endpoint
Headers
The validateAppApiKey middleware extracts the API key from the Authorization header.
Request Body
Response
Success:Implementation
- File:
packages/cloud/src/routes/auth.routes.ts:72-93 - Middleware:
validateAppApiKey- Validates app API key - Service: Uses
tokenService.exchangeTemporaryToken()
Exchange Store Token
Special endpoint for the MentraOS Store webview to get full tokens.Endpoint
Request Body
Response
Implementation
- File:
packages/cloud/src/routes/auth.routes.ts:96-145 - Validation: Only accepts
packageName: "org.augmentos.store" - Returns: Both Supabase and core tokens for full authentication
Hash with API Key
Create a hash using an app’s API key (for secure client-side verification).Endpoint
Headers
Request Body
Response
Implementation
- File:
packages/cloud/src/routes/auth.routes.ts:148-162 - Service: Uses
appService.hashWithApiKey() - Purpose: Allows apps to verify data integrity
Generate Signed User Token
Generate a signed JWT token for webview authentication in apps.Endpoint
Headers
Request Body
Response
Implementation
- File:
packages/cloud/src/routes/auth.routes.ts:176-199 - Service: Uses
tokenService.issueUserToken() - Signing: Uses RSA private key for client-side verification
- Expiration: 10 minutes
Error Codes
| Code | Description |
|---|---|
| 400 | Missing required parameters |
| 401 | Invalid or expired token |
| 403 | Forbidden (wrong package name) |
| 500 | Internal server error |
Security Notes
- All tokens should be transmitted over HTTPS
- Core tokens expire after a configured duration
- Temporary tokens are single-use and expire quickly
- API keys must be kept secret and never exposed client-side