Authentication
Flynapse provides multiple authentication methods to secure API access and ensure proper authorization for different use cases.Authentication Methods
1. JWT Bearer Token (Recommended)
JWT (JSON Web Token) authentication is the recommended method for most API interactions. It provides secure, stateless authentication with built-in expiration.Getting a JWT Token
Login Endpoint:Using JWT Tokens
Include the JWT token in the Authorization header:Token Refresh
When a JWT token expires, use the refresh token to get a new one:2. API Key Authentication
API keys are suitable for server-to-server communication and automated scripts. They provide long-term access without user interaction.Getting an API Key
- From Dashboard: Generate API keys from your Flynapse dashboard
- From Admin: Request API keys from your system administrator
Using API Keys
Include the API key in the X-API-Key header:3. OAuth 2.0 (Enterprise)
For enterprise customers, Flynapse supports OAuth 2.0 integration with your existing identity providers.Supported Providers
- Azure AD: Microsoft Azure Active Directory
- Okta: Okta Identity Platform
- Google Workspace: Google Workspace SSO
- Custom: Custom OAuth 2.0 providers
OAuth Flow
- Authorization Request: Redirect users to Flynapse authorization URL
- User Consent: User grants permission to your application
- Authorization Code: Flynapse returns an authorization code
- Token Exchange: Exchange code for access token
- API Access: Use access token for API requests
Authentication Headers
Required Headers
All authenticated requests must include one of the following headers:Optional Headers
User Roles and Permissions
Flynapse implements role-based access control (RBAC) with the following roles:Available Roles
| Role | Description | Permissions |
|---|---|---|
admin | System Administrator | Full access to all features and user management |
manager | Team Manager | Access to team data, user management within team |
engineer | Maintenance Engineer | Document access, search, commenting, sharing |
viewer | Read-only User | Document viewing and search only |
api_user | API-only User | Programmatic access via API keys |
Permission Matrix
| Feature | Admin | Manager | Engineer | Viewer | API User |
|---|---|---|---|---|---|
| Document Search | ✅ | ✅ | ✅ | ✅ | ✅ |
| Document Viewing | ✅ | ✅ | ✅ | ✅ | ✅ |
| Document Comments | ✅ | ✅ | ✅ | ❌ | ❌ |
| Document Sharing | ✅ | ✅ | ✅ | ❌ | ❌ |
| User Management | ✅ | ✅ | ❌ | ❌ | ❌ |
| System Settings | ✅ | ❌ | ❌ | ❌ | ❌ |
| API Access | ✅ | ✅ | ✅ | ❌ | ✅ |
Security Best Practices
1. Token Management
- Store Securely: Store tokens in secure environment variables or secret management systems
- Rotate Regularly: Regularly rotate API keys and refresh JWT tokens
- Monitor Usage: Monitor token usage for suspicious activity
- Scope Minimally: Use the minimum required permissions for each application
2. Network Security
- Use HTTPS: Always use HTTPS for API communications
- Validate Certificates: Verify SSL certificates to prevent man-in-the-middle attacks
- Rate Limiting: Respect rate limits and implement exponential backoff
3. Error Handling
- Handle 401 Errors: Implement proper token refresh logic
- Log Security Events: Log authentication failures and suspicious activity
- Graceful Degradation: Handle authentication failures gracefully
Error Responses
Authentication Errors
Permission Errors
Code Examples
Python SDK
JavaScript SDK
cURL Examples
Session Management
JWT Token Lifecycle
- Login: User authenticates and receives JWT token
- API Requests: Token used for authenticated requests
- Expiration: Token expires after configured time (default: 1 hour)
- Refresh: Use refresh token to get new access token
- Logout: Invalidate tokens on logout
Session Configuration
Multi-Factor Authentication (MFA)
Enterprise customers can enable MFA for enhanced security:MFA Methods
- SMS: One-time codes sent via SMS
- Email: One-time codes sent via email
- TOTP: Time-based one-time passwords (Google Authenticator, Authy)
- Hardware Tokens: Physical security keys (YubiKey)
MFA Flow
- Login Attempt: User provides email/password
- MFA Challenge: System requests second factor
- Verification: User provides MFA code
- Token Issuance: System issues JWT token upon successful verification
Troubleshooting
Common Issues
| Issue | Cause | Solution |
|---|---|---|
| 401 Unauthorized | Expired or invalid token | Refresh JWT token or regenerate API key |
| 403 Forbidden | Insufficient permissions | Contact admin to update user role |
| 429 Too Many Requests | Rate limit exceeded | Implement exponential backoff |
| 500 Internal Server Error | Server-side issue | Contact support with request ID |
Debug Information
Include debug headers for troubleshooting:Support
For authentication issues:- Documentation: This authentication guide
- Support Email: [email protected]
- Community Forum: community.flynapse.ai
- Emergency Contact: [email protected] (for security incidents)
Secure your Flynapse integration with proper authentication