#44 [Admin Panel] Token Management API - Generate Token
Description
EditImplement POST /api/v1/admin/tokens endpoint to generate JWT tokens for users.
**API Specification:**
- Endpoint: POST /api/v1/admin/tokens
- Permission Required: manage_users
- Request Body: {user_id, expires_in_hours?, description?, scopes[]?}
- Response: {token_id, token, expires_at, user_id, description}
**Requirements:**
- Generate JWT with configurable expiration (default: 24h, max: 8760h/1year)
- Optional token description for identification
- Optional scope limitation (subset of user's permissions)
- Store token metadata in database for tracking
- Log audit event for token generation
**Token Tracking Table:**
- token_id (UUID), user_id, tenant_id
- token_hash (SHA256 of token for lookup)
- description, scopes[]
- created_at, expires_at, last_used_at
- created_by, is_revoked
**Use Cases:**
- Service accounts
- Long-lived API access
- Temporary elevated access
**IMPORTANT:** Implement with ultra attention to details and correctness.
**BEFORE CLOSING:** Take screenshot showing token generation. Add comment summarizing implementation.
Comments
Loading comments...
Context
Loading context...
Audit History
View AllLoading audit history...