AccessToken implements JsonSerializable
The validated access token a request was authorized with.
The HTTP transports read it from the PSR-7 request attribute AccessToken::class
and expose it to handlers through RequestContext::getAccessToken().
AuthorizationMiddleware sets that attribute;
an application authenticating requests itself sets it instead. It only lives for the
request it arrived with: it is never written to a session store, so a
request without a token never inherits an earlier one.
Tags
Table of Contents
Interfaces
- JsonSerializable
Properties
Methods
- __construct() : mixed
- getClaim() : mixed
- getClaims() : array<string, mixed>
- getClientId() : string|null
- The client the token was issued to: `client_id` (RFC 9068), falling back to `azp` (OpenID Connect).
- getPrincipal() : string
- Who the token identifies: its issuer, client and subject, which outlive a token refresh.
- getScopes() : array<int, string>
- getSubject() : string|null
- The resource owner the token was issued for (`sub`).
- hasScope() : bool
- jsonSerialize() : mixed
- Never serialized: the token must not outlive its request in a session store.
Properties
$claims read-only
private
array<string|int, mixed>
$claims
= []
$scopes read-only
private
array<string|int, mixed>
$scopes
= []
Methods
__construct()
public
__construct([array<int, string> $scopes = [] ][, array<string, mixed> $claims = [] ]) : mixed
Parameters
- $scopes : array<int, string> = []
-
scopes granted to the token
- $claims : array<string, mixed> = []
-
claims of the token, e.g. a JWT payload or an introspection response
getClaim()
public
getClaim(string $name) : mixed
Parameters
- $name : string
getClaims()
public
getClaims() : array<string, mixed>
Return values
array<string, mixed>getClientId()
The client the token was issued to: `client_id` (RFC 9068), falling back to `azp` (OpenID Connect).
public
getClientId() : string|null
Return values
string|nullgetPrincipal()
Who the token identifies: its issuer, client and subject, which outlive a token refresh.
public
getPrincipal() : string
Return values
stringgetScopes()
public
getScopes() : array<int, string>
Return values
array<int, string>getSubject()
The resource owner the token was issued for (`sub`).
public
getSubject() : string|null
Return values
string|nullhasScope()
public
hasScope(string $scope) : bool
Parameters
- $scope : string
Return values
booljsonSerialize()
Never serialized: the token must not outlive its request in a session store.
public
jsonSerialize() : mixed