AuthorizationResult
Describes the outcome of an authorization decision.
Use the static factory methods to create instances:
- allow() - Access is granted
- unauthorized() - No valid credentials provided (401)
- forbidden() - Valid credentials but insufficient permissions (403)
- badRequest() - Malformed request (400)
- unavailable() - Token validation temporarily unavailable (503)
Tags
Table of Contents
Properties
- $accessToken : AccessToken|null
- $allowed : bool
- $error : string|null
- $errorDescription : string|null
- $retryAfter : int|null
- $scopes : array<string|int, mixed>|null
- $statusCode : int
Methods
- allow() : self
- Creates a result indicating access is allowed.
- badRequest() : self
- Creates a result indicating a bad request (400).
- forbidden() : self
- Creates a result indicating the request is forbidden (403).
- getAccessToken() : AccessToken|null
- The validated token; set only on an allowed result.
- getError() : string|null
- getErrorDescription() : string|null
- getRetryAfter() : int|null
- getScopes() : array<int, string>|null
- getStatusCode() : int
- isAllowed() : bool
- unauthorized() : self
- Creates a result indicating the request is unauthorized (401).
- unavailable() : self
- __construct() : mixed
Properties
$accessToken read-only
private
AccessToken|null
$accessToken
$allowed read-only
private
bool
$allowed
$error read-only
private
string|null
$error
$errorDescription read-only
private
string|null
$errorDescription
$retryAfter read-only
private
int|null
$retryAfter
= null
$scopes read-only
private
array<string|int, mixed>|null
$scopes
$statusCode read-only
private
int
$statusCode
Methods
allow()
Creates a result indicating access is allowed.
public
static allow(AccessToken $accessToken) : self
Parameters
- $accessToken : AccessToken
Return values
selfbadRequest()
Creates a result indicating a bad request (400).
public
static badRequest([string|null $error = 'invalid_request' ][, string|null $errorDescription = null ]) : self
Use when the Authorization header is malformed.
Parameters
- $error : string|null = 'invalid_request'
-
OAuth error code (defaults to "invalid_request")
- $errorDescription : string|null = null
-
Human-readable error description
Return values
selfforbidden()
Creates a result indicating the request is forbidden (403).
public
static forbidden([string|null $error = 'insufficient_scope' ][, string|null $errorDescription = null ][, array<int, string>|null $scopes = null ]) : self
Use when the token is valid but lacks required permissions/scopes.
Parameters
- $error : string|null = 'insufficient_scope'
-
OAuth error code (defaults to "insufficient_scope")
- $errorDescription : string|null = null
-
Human-readable error description
- $scopes : array<int, string>|null = null
-
Required scopes to include in challenge
Return values
selfgetAccessToken()
The validated token; set only on an allowed result.
public
getAccessToken() : AccessToken|null
Return values
AccessToken|nullgetError()
public
getError() : string|null
Return values
string|nullgetErrorDescription()
public
getErrorDescription() : string|null
Return values
string|nullgetRetryAfter()
public
getRetryAfter() : int|null
Return values
int|nullgetScopes()
public
getScopes() : array<int, string>|null
Return values
array<int, string>|nullgetStatusCode()
public
getStatusCode() : int
Return values
intisAllowed()
public
isAllowed() : bool
Return values
boolunauthorized()
Creates a result indicating the request is unauthorized (401).
public
static unauthorized([string|null $error = null ][, string|null $errorDescription = null ][, array<int, string>|null $scopes = null ]) : self
Use when no valid credentials are provided or the token is invalid.
Parameters
- $error : string|null = null
-
OAuth error code (e.g., "invalid_token")
- $errorDescription : string|null = null
-
Human-readable error description
- $scopes : array<int, string>|null = null
-
Required scopes to include in challenge
Return values
selfunavailable()
public
static unavailable([int|null $retryAfter = null ]) : self
Parameters
- $retryAfter : int|null = null
-
Suggested delay before retrying, in seconds
Tags
Return values
self__construct()
private
__construct(bool $allowed, int $statusCode, string|null $error, string|null $errorDescription, array<int, string>|null $scopes, AccessToken|null $accessToken[, int|null $retryAfter = null ]) : mixed
Parameters
- $allowed : bool
- $statusCode : int
- $error : string|null
- $errorDescription : string|null
- $scopes : array<int, string>|null
-
Scopes to include in WWW-Authenticate challenge
- $accessToken : AccessToken|null
- $retryAfter : int|null = null