-
Notifications
You must be signed in to change notification settings - Fork 5
API Exceptions AuthenticationError
Authentication error types for the OpenFGA SDK. Defines specific authentication failure scenarios that can occur when interacting with the OpenFGA API, such as expired or invalid tokens. Each case provides a factory method to create the corresponding AuthenticationException with appropriate context. Authentication errors typically occur during the OAuth 2.0 flow or when using access tokens with OpenFGA API requests. These errors indicate that the provided credentials are no longer valid or were never valid, requiring token refresh or re-authentication.
Table of Contents
OpenFGA\Exceptions
UnitEnumBackedEnum
| Name | Value | Description |
|---|---|---|
TokenExpired |
token_expired |
Access token has expired and needs to be refreshed. Occurs when an access token's expiration time has passed, requiring a new token to be obtained through the OAuth flow. |
TokenInvalid |
token_invalid |
Access token is invalid or malformed. Occurs when the provided token is not recognized by the authorization server or has an invalid format. |
| Name | Value | Description |
|---|---|---|
TokenExpired |
token_expired |
Access token has expired and needs to be refreshed. Occurs when an access token's expiration time has passed, requiring a new token to be obtained through the OAuth flow. |
TokenInvalid |
token_invalid |
Access token is invalid or malformed. Occurs when the provided token is not recognized by the authorization server or has an invalid format. |
public function exception(
RequestInterface|null $request = NULL,
ResponseInterface|null $response = NULL,
array<string, mixed> $context = [],
Throwable|null $prev = NULL,
): AuthenticationExceptionCreate a new AuthenticationException for this error type. Factory method that creates an AuthenticationException instance with the current error type and provided context information. This provides a convenient way to generate typed exceptions with proper error categorization and rich debugging context for OpenFGA authentication failures. The exception will automatically capture the correct file and line location where this method was called (typically where throw occurs), ensuring debuggers show the actual throw location rather than this factory method.
| Name | Type | Description |
|---|---|---|
$request |
RequestInterface | null
|
The PSR-7 HTTP request that triggered the authentication failure, if applicable |
$response |
ResponseInterface | null
|
The PSR-7 HTTP response containing authentication error details, if applicable |
$context |
array<string, mixed>
|
|
$prev |
Throwable | null
|
The previous throwable used for exception chaining, if any |
AuthenticationException — The newly created AuthenticationException instance with comprehensive error context
public function getUserMessage(string|null $locale = NULL): stringGet a user-friendly error message for this authentication error. Provides appropriate messaging for different authentication failures that can be displayed to end users or used in error logs. Messages are localized using the translation system.
| Name | Type | Description |
|---|---|---|
$locale |
string | null
|
Optional locale override for message translation |
string — A descriptive, localized error message
public function isTokenRefreshable(): boolCheck if this authentication error indicates the token should be refreshed. Useful for implementing automatic token refresh logic in OAuth flows.
bool — True if token refresh should be attempted, false otherwise
Getting Started: Introduction • Installation • Authentication
Essentials: Stores • Authorization Models • Relationship Tuples • Permissions Queries
Features: Helper Functions • Concurrency • Results • Exceptions • Observability • Integration
- API Reference - Full class and method documentation
- Quickstart - Get up and running in minutes
- Helpers - Convenient shortcuts for common operations
- Testing Guide - Unit testing with the SDK
- Performance Guide - Optimize for high-scale applications
- Report Issues - Bug reports and feature requests
- Discussions - Community support and questions
- Contributing - Help improve the SDK
- Changelog - Latest updates and releases
- OpenFGA Documentation - Official OpenFGA documentation
- OpenFGA Playground - Interactive modeling environment
- Authorization Concepts - Learn relationship-based access control
- Other SDKs - JavaScript, Go, Python, .NET, and more
OpenFGA PHP SDK • Apache 2.0 License
- Authorization Stores
- Authorization Models
- Relationship Tuples
- Permission Queries
- Testing with Assertions
- Helper Functions
- Concurrency
- Error Handling
- Framework Integration
- OpenTelemetry Observability
- Result Pattern
- Event Dispatcher
- HTTP Request Sent Event
- HTTP Response Received Event
- Operation Started Event
- Operation Completed Event
- More Events …
- Authentication Exception
- Client Exception
- Configuration Exception
- Network Exception
- Serialization Exception
- More Exceptions …
- Request Manager
- Request Context
- Circuit Breaker
- Parallel Task Executor
- Fiber Concurrent Executor
- Simple Concurrent Executor
- Retry Handler
- Exponential Backoff Retry Strategy
- More Networking …