Repository navigation
OAuth2Client
Viames Marino edited this page Oct 19, 2026
·
2 revisions
Pair\Models\OAuth2Client manages OAuth2 client credentials and token issuance.
issueAccessToken(): stringsendAccessTokenResponse(): voidgenerateSecret(int $bytes = 32): string
Lifecycle/config:
-
_init()defines fields and validation rules
use Pair\Models\OAuth2Client;
$client = OAuth2Client::find($clientId);
if (!$client or !$client->enabled) {
throw new RuntimeException('Invalid client');
}
$token = $client->issueAccessToken();- Designed for server-to-server OAuth flows.
- The client identifier is the
idprimary key; availability is stored inenabled. - This example assumes the caller has already authenticated the client secret. Finding an enabled client by ID alone does not authenticate it.
-
issueAccessToken()reuses and refreshes a valid token or creates one, then removes other tokens for that client. -
sendAccessTokenResponse()writes standardized token payload output and terminates execution.
See also: OAuth2Token, ApiController.
Maintained by Viames Marino — VM Ingegneria · Professional enquiries
Home · Setup · Configuration
Build with Pair 4
- Generator
- Controllers and responses
- Read models
- ActiveRecord and queries
- Forms and validation
- PairUI.js and HTML fragments
APIs and authentication
- API guide and CRUD
- Middleware and rate limits
- Users, sessions, and ACL
- Passkeys and social login
- Native mobile setup
Integrate and operate
- Integrations
- Runtime extensions and adapter keys
- Cache and cache stores
- Logs and observability
- PWA and push
- Packages and distribution
- Upgrade to v4