Skip to content

OAuth2Client

Viames Marino edited this page Feb 23, 2026 · 1 revision

Pair framework: OAuth2Client

Pair\Models\OAuth2Client manages OAuth2 client credentials and token issuance.

Main methods

  • issueAccessToken(): string
  • sendAccessTokenResponse(): void

Lifecycle/config:

  • _init() defines fields and validation rules

Implementation example

$client = \Pair\Models\OAuth2Client::findByClientId($clientId);

if (!$client || !$client->active) {
    throw new RuntimeException('Invalid client');
}

$token = $client->issueAccessToken();

Notes

  • Designed for server-to-server OAuth flows.
  • sendAccessTokenResponse() writes standardized token payload output.

See also: OAuth2Token, ApiController.

Clone this wiki locally