{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/pipeshub/json-schema/pipeshub-oauth-token-request-schema.json",
  "title": "OAuthTokenRequest",
  "description": "OAuth 2.0 Token Request (RFC 6749 Section 4.1.3).\nRequest body for exchanging authorization code or credentials for tokens.\n",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/pipeshub-oauth-provider-api-openapi.yml#/components/schemas/OAuthTokenRequest",
  "type": "object",
  "properties": {
    "grant_type": {
      "type": "string",
      "enum": [
        "authorization_code",
        "client_credentials",
        "refresh_token"
      ],
      "description": "OAuth grant type:\n- `authorization_code`: Exchange auth code for tokens\n- `client_credentials`: Machine-to-machine auth\n- `refresh_token`: Get new access token using refresh token\n"
    },
    "code": {
      "type": "string",
      "description": "Authorization code (required for authorization_code grant)"
    },
    "redirect_uri": {
      "type": "string",
      "format": "uri",
      "description": "Redirect URI (required for authorization_code grant)"
    },
    "client_id": {
      "type": "string",
      "description": "Client ID (can also be sent via Basic auth header)"
    },
    "client_secret": {
      "type": "string",
      "description": "Client secret (can also be sent via Basic auth header)"
    },
    "refresh_token": {
      "type": "string",
      "description": "Refresh token (required for refresh_token grant)"
    },
    "scope": {
      "type": "string",
      "description": "Requested scopes (optional, defaults to original grant scopes)"
    },
    "code_verifier": {
      "type": "string",
      "description": "PKCE code verifier (RFC 7636). Required if code_challenge was used.\nMust be 43-128 characters from [A-Za-z0-9-._~]\n",
      "pattern": "^[A-Za-z0-9\\-._~]{43,128}$"
    }
  },
  "required": [
    "grant_type"
  ]
}