---
title: "Token"
method: POST
path: "/token"
tags: ["Authentication"]
---

# Token

`POST /token`

OAuth2 token endpoint. Exchanges authorization code for access tokens.
    
    **Request Body (JSON or Form):**
    - `grant_type`: OAuth2 grant type - "authorization_code" or "refresh_token" (required)
    - `code`: Authorization code from OAuth2 callback (required for authorization_code grant)
    - `redirect_uri`: Redirect URI used in authorization (required for authorization_code grant)
    - `client_type`: Client type - "papr_plugin" or "browser_extension" (optional, default: papr_plugin)
    - `refresh_token`: Refresh token for token refresh (required for refresh_token grant)
    
    **Response:**
    - `access_token`: OAuth2 access token for API authentication
    - `token_type`: Token type (Bearer)
    - `expires_in`: Token expiration time in seconds
    - `refresh_token`: Refresh token for getting new access tokens
    - `scope`: OAuth2 scopes granted
    - `user_id`: User ID from Auth0
    
    **Example Request:**
    ```json
    {
        "grant_type": "authorization_code",
        "code": "abc123...",
        "redirect_uri": "https://chat.openai.com",
        "client_type": "papr_plugin"
    }
    ```

## Response `200`

OAuth2 token exchange successful

- TokenResponse — Response model for OAuth2 token endpoint
  - `access_token` string, required — OAuth2 access token
  - `token_type` string — Token type
  - `expires_in` integer, required — Token expiration time in seconds
  - `refresh_token` string, nullable — Refresh token for getting new access tokens
  - `scope` string, required — OAuth2 scopes granted
  - `user_id` string, nullable — User ID from Auth0
  - `message` string, nullable — Additional message or status

## Other responses

- `400` — Bad request - invalid grant type or missing parameters
- `401` — Unauthorized - invalid authorization code
- `415` — Unsupported Media Type
- `500` — Internal server error

---

[API](https://skmtc.net/papr-ai/apis/papr-memory-api.md) · [All operations](https://skmtc.net/papr-ai/apis/papr-memory-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/papr-ai/papr-memory-api/versions/b553be9aad37/schema)
