Skip to main content

Authentication

Flynapse provides multiple authentication methods to secure API access and ensure proper authorization for different use cases.

Authentication Methods

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:
Request Body:
Response:

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:
Request Body:

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

  1. From Dashboard: Generate API keys from your Flynapse dashboard
  2. 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

  1. Authorization Request: Redirect users to Flynapse authorization URL
  2. User Consent: User grants permission to your application
  3. Authorization Code: Flynapse returns an authorization code
  4. Token Exchange: Exchange code for access token
  5. 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

Permission Matrix

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

  1. Login: User authenticates and receives JWT token
  2. API Requests: Token used for authenticated requests
  3. Expiration: Token expires after configured time (default: 1 hour)
  4. Refresh: Use refresh token to get new access token
  5. 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

  1. Login Attempt: User provides email/password
  2. MFA Challenge: System requests second factor
  3. Verification: User provides MFA code
  4. Token Issuance: System issues JWT token upon successful verification

Troubleshooting

Common Issues

Debug Information

Include debug headers for troubleshooting:

Support

For authentication issues:
Secure your Flynapse integration with proper authentication