Skip to main content

Overview

OpenSight supports multiple authentication methods to suit different use cases:
  • JWT Access Tokens - For web applications and user-specific requests
  • API Keys - For server-to-server integrations and automation
  • OAuth 2.0 - For third-party integrations (GitHub, Google)

JWT Access Tokens

JWT (JSON Web Token) access tokens are the primary authentication method for user-authenticated requests. Tokens are obtained through registration, login, or OAuth flows.

Token Lifecycle

  • Access Token: Short-lived (15 minutes) - Used for API requests
  • Refresh Token: Long-lived (30 days) - Used to obtain new access tokens
Access tokens are sent in the Authorization header, while refresh tokens are stored in HTTP-only cookies for security.

Obtaining Access Tokens

Response Format

The refresh_token is automatically set as an HTTP-only cookie:

Using Access Tokens

Include the access token in the Authorization header with the Bearer scheme:
Access tokens expire after 15 minutes. Use the refresh token endpoint to obtain a new access token before it expires.

Token Refresh Flow

When your access token expires (401 Unauthorized), refresh it using the refresh token:
Response:
A new refresh token is also issued and set as a cookie.

Logout

Revoke the refresh token when logging out:
Response:

API Keys

API keys are ideal for server-to-server integrations, automation scripts, and machine-to-machine communication. They don’t expire and can be revoked at any time.

Key Format

API keys use the format: sk_ followed by 64 hexadecimal characters
API keys are displayed only once during creation. Store them securely - you won’t be able to view the full key again.

Creating API Keys

Using API Keys

Include the API key in the Authorization header with the Bearer scheme:

Managing API Keys

List response:
Delete response:

Plan Limits

API key creation is subject to plan limits:

OAuth 2.0

OpenSight supports OAuth authentication with GitHub and Google for seamless third-party login.

GitHub OAuth

Google OAuth

OAuth User Linking

When a user authenticates via OAuth:
  1. New user: A new account is created with email_verified: true
  2. Existing email: The OAuth provider is linked to the existing account
  3. Existing OAuth ID: The user is logged in directly

Password Reset

Users can reset their password via email:
Response:
Reset tokens expire after 1 hour and can only be used once.

Security Best Practices

Token Storage

  • Access Tokens: Store in memory or secure state management (never localStorage)
  • Refresh Tokens: Stored as HTTP-only cookies by the API automatically
  • API Keys: Store in environment variables or secure secret management systems

HTTPS Only

In production (NODE_ENV=production), cookies are marked as Secure and require HTTPS:

Error Handling

Handle authentication errors gracefully:

Next Steps

API Overview

Learn about API structure and response formats

API Endpoints

Explore available API endpoints