Simple Authentication

Simple Authentication Method

Simple authentication uses a Bearer token to authenticate API requests through the MyAppToken proxy.

How It Works
  1. Create an application in the Applications section
  2. Add a service (e.g., OpenAI) to your application
  3. Add an upstream API token for the service
  4. Obtain a JWT token using the /auth/simple endpoint
  5. Use the JWT token in the Authorization header of your API requests
Step 1: Obtain a JWT Token

Make a POST request to the /api/v1/auth/simple endpoint with your app UUID and a user identifier:

curl -X POST https://api.myapptoken.com/api/v1/auth/simple \
  -H "Content-Type: application/json" \
  -d '{
    "app_id": "550e8400-e29b-41d4-a716-446655440000",
    "user_id": "user-123"
  }'
Response
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "expires_at": "2024-01-15T12:00:00Z"
}
Note: The app_id is the UUID of your application (found in the Applications section). The user_id is a unique identifier for tracking usage per user.
Step 2: Use the JWT Token

Include the access_token from the response in the Authorization header:

Authorization: Bearer <access_token>
Example Request

Here's an example using curl to make a request to OpenAI through MyAppToken:

curl https://api.myapptoken.com/api/v1/proxy/my-app/openai/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <access_token>" \
  -d '{
    "model": "gpt-4",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'
Benefits
  • Simplified key management - Manage all your API keys in one place
  • Usage tracking - Monitor API usage per token
  • Easy rotation - Rotate tokens without changing upstream API keys
  • Access control - Create separate tokens for different environments or team members