Authentication Guide

This guide covers authentication methods and best practices for the BlueNexus AI platform.

Authentication Methods

API Key Authentication

The simplest way to authenticate with the BlueNexus AI API:

curl -X GET "https://api.bluenexus.ai/api/v1/accounts/me" \
  -H "Authorization: Bearer YOUR_API_KEY"

Creating API Keys

  1. Log into your BlueNexus AI dashboard

  2. Navigate to Settings → API Keys

  3. Click Create New API Key

  4. Give your key a descriptive name

  5. Select appropriate scopes

  6. Copy the generated key (you won't see it again!)

API Key Scopes

  • api:read - Read access to API resources

  • api:write - Write access to API resources

  • api:admin - Administrative access

  • connections:read - Read connection data

  • connections:write - Manage connections

  • data:read - Read data collections

  • data:write - Write data collections

  • llm:read - Access LLM services

  • mcp:read - Access MCP servers

  • mcp:write - Manage MCP servers

OAuth 2.0 Authentication

For applications that need to access user data:

Authorization Code Flow

Token Refresh

Personal Access Tokens

For long-term API access:

SDK Authentication

Python SDK

JavaScript SDK

Go SDK

Security Best Practices

API Key Security

  1. Never commit API keys to version control

  2. Use environment variables for API keys

  3. Rotate API keys regularly

  4. Use the principle of least privilege

  5. Monitor API key usage

OAuth Security

  1. Use HTTPS for all OAuth flows

  2. Validate state parameters

  3. Store tokens securely

  4. Implement token refresh

  5. Handle token expiration gracefully

Token Management

  1. Implement automatic token refresh

  2. Handle token expiration

  3. Store tokens securely

  4. Revoke unused tokens

  5. Monitor token usage

Error Handling

Common Authentication Errors

Error Code
Description
Solution

401 Unauthorized

Invalid or missing credentials

Check API key or token

403 Forbidden

Insufficient permissions

Check scopes and permissions

429 Too Many Requests

Rate limit exceeded

Implement backoff strategy

Token Expired

Access token expired

Refresh the token

Error Handling Example

Multi-Factor Authentication

Enabling 2FA

  1. Log into your BlueNexus AI dashboard

  2. Navigate to Settings → Security

  3. Click Enable Two-Factor Authentication

  4. Scan the QR code with your authenticator app

  5. Enter the verification code

  6. Save your recovery codes

2FA with API

When 2FA is enabled, some operations require additional verification:

Testing Authentication

Test API Key

Use the test endpoint to verify your authentication:

Response

Troubleshooting

Common Issues

  1. Invalid API Key: Check that your API key is correct and active

  2. Expired Token: Refresh your access token

  3. Insufficient Scopes: Check that your token has the required scopes

  4. Rate Limiting: Implement exponential backoff

  5. Network Issues: Check your network connection and firewall settings

Debug Mode

Enable debug mode for detailed error information:

Last updated