> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ofauth.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Exchange an authorization code or refresh token

> Token endpoint (RFC 6749). Use one client authentication method: HTTP Basic or form client_id and client_secret. Authorization code exchange requires exact redirect_uri and S256 PKCE. Refresh returns a new access token and echoes the same refresh token; concurrent refreshes and lost refresh responses do not consume it. No public clients or client_credentials grant.



## OpenAPI

````yaml /openapi/v3.json post /v3/link/token
openapi: 3.1.0
info:
  title: OFAuth API
  version: 1.0.0
  description: >-
    OFAuth V3 API for linking accounts, making OnlyFans API requests, and
    receiving events.
  contact:
    email: support@ofauth.com
    url: https://ofauth.com/
servers:
  - url: https://api.ofauth.com
security:
  - ExternalOAuth: []
tags:
  - name: Link
    description: Link accounts, get and refresh tokens, and end access.
  - name: Linked accounts
    description: The linked accounts of one authorization, and their settings.
  - name: Access
    description: Make OnlyFans API requests for a linked account.
  - name: Analytics
    description: 'Access: charts, rankings, and performance data.'
  - name: Earnings
    description: 'Access: earnings charts, transactions, and chargebacks.'
  - name: Messages
    description: 'Access: messaging, chats, queue, and mass messaging.'
  - name: Posts
    description: 'Access: create, edit, list, and manage posts.'
  - name: Promotions
    description: 'Access: promotions, trials, and bundles.'
  - name: Users
    description: 'Access: user profiles, subscriptions, and actions.'
  - name: Vault
    description: 'Access: vault folders, media, and management.'
  - name: Upload
    description: 'Access: media upload and processing.'
  - name: Self
    description: 'Access: linked account profile and settings.'
  - name: Stories
    description: 'Access: stories listing and management.'
  - name: Subscriptions
    description: 'Access: subscription offers, discounts, and management.'
  - name: Realtime
    description: Webhook event formats, including OnlyFans activity events.
externalDocs:
  description: OFAuth Developer Documentation
  url: https://docs.ofauth.com
paths:
  /v3/link/token:
    post:
      tags:
        - Link
      summary: Exchange an authorization code or refresh token
      description: >-
        Token endpoint (RFC 6749). Use one client authentication method: HTTP
        Basic or form client_id and client_secret. Authorization code exchange
        requires exact redirect_uri and S256 PKCE. Refresh returns a new access
        token and echoes the same refresh token; concurrent refreshes and lost
        refresh responses do not consume it. No public clients or
        client_credentials grant.
      operationId: linkToken
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                grant_type:
                  type: string
                  enum:
                    - authorization_code
                    - refresh_token
                client_id:
                  type: string
                  description: Required with client_secret_post. Omit with HTTP Basic.
                client_secret:
                  type: string
                  description: Required with client_secret_post. Omit with HTTP Basic.
                code:
                  type: string
                  description: Required for `authorization_code`.
                redirect_uri:
                  type: string
                  format: uri
                  description: Required for `authorization_code`.
                code_verifier:
                  type: string
                  description: PKCE verifier. Required for `authorization_code`.
                refresh_token:
                  type: string
                  description: Required for `refresh_token`.
                scope:
                  type: string
                  description: >-
                    Optional narrower scope for the new access token; never
                    expands or mutates the renewable credential.
                resource:
                  type: string
                  description: >-
                    Not needed. Accepted only for OAuth client libraries that
                    always send a resource indicator (RFC 8707): it must equal
                    `https://api.ofauth.com/v3` and is not stored.
                  format: uri
              required:
                - grant_type
      responses:
        '200':
          description: Token issued.
          headers:
            Cache-Control:
              schema:
                type: string
                example: no-store
              required: true
            Pragma:
              schema:
                type: string
                example: no-cache
              required: true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LinkTokenResponse'
        '400':
          description: >-
            `invalid_request`, `invalid_grant`, `invalid_scope`,
            `invalid_target`, `unauthorized_client`, or `unsupported_grant_type`
            (RFC 6749 section 5.2).
          headers:
            Cache-Control:
              schema:
                type: string
                example: no-store
              required: true
            Pragma:
              schema:
                type: string
                example: no-cache
              required: true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LinkOAuthError'
        '401':
          description: '`invalid_client`: missing or wrong client credentials.'
          headers:
            Cache-Control:
              schema:
                type: string
                example: no-store
              required: true
            Pragma:
              schema:
                type: string
                example: no-cache
              required: true
            WWW-Authenticate:
              schema:
                type: string
                example: Basic realm="link", charset="UTF-8"
              required: true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LinkOAuthError'
        '429':
          description: '`rate_limited`; retry after `Retry-After` seconds.'
          headers:
            Cache-Control:
              schema:
                type: string
                example: no-store
              required: true
            Pragma:
              schema:
                type: string
                example: no-cache
              required: true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LinkOAuthError'
      security:
        - ClientSecretBasic: []
        - {}
components:
  schemas:
    LinkTokenResponse:
      type: object
      properties:
        access_token:
          type: string
          description: >-
            Opaque access token. Present it only as a Bearer resource
            credential.
        token_type:
          type: string
          enum:
            - Bearer
        expires_in:
          type: integer
          minimum: 0
          exclusiveMinimum: true
          example: 900
        refresh_token:
          type: string
          description: >-
            Stable renewable credential bound to this confidential client.
            Returned on every code exchange and echoed on refresh. Expires after
            90 days without successful authenticated refresh.
        scope:
          type: string
          example: identity:read profile:read
        authorization_id:
          type: string
          description: >-
            Informational authorization identifier. Discover accounts through
            GET /v3/linked-accounts.
      required:
        - access_token
        - token_type
        - expires_in
        - refresh_token
        - scope
    LinkOAuthError:
      type: object
      properties:
        error:
          type: string
          enum:
            - invalid_request
            - invalid_client
            - invalid_grant
            - invalid_scope
            - invalid_target
            - unauthorized_client
            - unsupported_grant_type
            - rate_limited
            - server_error
          description: RFC 6749 section 5.2 error code.
        error_description:
          type: string
          example: request rejected
        reason:
          type: string
          description: Present when the client lifecycle blocks the grant.
          example: security_suspended
        recovery:
          type: object
          properties:
            action:
              type: string
          required:
            - action
      required:
        - error
  securitySchemes:
    ExternalOAuth:
      type: http
      scheme: bearer
      bearerFormat: opaque
      description: Link access token for one Sandbox, Test, or Live authorization.
    ClientSecretBasic:
      type: http
      scheme: basic
      description: >-
        Client ID and client secret (`client_secret_basic`, RFC 6749 section
        2.3.1).

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.