Skip to content
Viames Marino edited this page Nov 6, 2026 · 1 revision

Pair framework: OAuth2

Pair\Api\OAuth2 provides storage-independent RFC 6749 protocol helpers.

  • decode(string $value): string: form decoding with complete percent escapes and valid UTF-8.
  • parameters(string $body): array: reject repeated parameter names; treat empty values as omitted. Retained unknown fields must be ignored by callers unless an explicitly supported extension recognizes them.
  • clientCredentials(?string $header): ?array: strict Basic parsing followed by one form decode per component, without credential trimming.
  • tokenPayload(string $token, int $lifetime, ?string $scope = null): array: positive expiry, Bearer token, optional nonempty scope; never scope=null or refresh token.
  • errorPayload(string $code, ?string $description = null): array: token-endpoint codes and the ASCII character set required for error_description. temporarily_unavailable is not a base token-endpoint error.
  • tokenResponse(...) and errorResponse(...): explicit JsonResponse, mandatory no-store/no-cache headers protected against case-insensitive overrides. Invalid client authentication produces 401 with a Basic challenge; other OAuth errors use 400.

Transport, availability and rate-limit errors are ordinary HTTP errors; use Problem Details separately. Client authentication, scope grants, TLS, abuse prevention and resource ownership remain the application's responsibilities. No new database table or configuration variable is required.

These helpers and the related HTTP fixes are in the current development source; they are not implicitly present in the existing 4.1.4 package. Consumers must install a release containing them or apply the reviewed compatibility patch.

Clone this wiki locally