API Authentication AccessTokenInterface - evansims/openfga-php GitHub Wiki
Represents an access token for OpenFGA API authentication. Access tokens are credentials used to authenticate requests to the OpenFGA API. They are typically obtained through OAuth 2.0 flows (such as client credentials) and have a limited lifespan defined by their expiration time. Access tokens provide secure, time-limited access to OpenFGA resources without requiring the transmission of long-lived credentials with each request. This interface defines the contract for managing these tokens, including: - Token value retrieval for Authorization headers - Expiration checking to determine when token refresh is needed - Scope validation for permission boundaries - Token parsing from OAuth server responses
Table of Contents
OpenFGA\Authentication
Stringable
- AccessToken (implementation)
public function getExpires(): intGet the Unix timestamp when this access token expires. The expiration timestamp indicates when the token is no longer valid for API requests. Applications should check this value before making requests and refresh the token when necessary to avoid authentication failures.
int — Unix timestamp representing when the token expires
public function getScope(): string|nullGet the scope that defines the permissions granted by this access token. The scope represents the extent of access granted to the token bearer. Different scopes may provide access to different OpenFGA operations or resources. A null scope typically indicates full access or that scope restrictions are not applicable for this token.
string | null — The token scope defining granted permissions, or null if no scope is specified
public function getToken(): stringGet the raw access token value. This method returns the actual token string that was issued by the authentication server. This is the same value returned by __toString() but provided as an explicit getter method for clarity.
string — The raw access token value
public function isExpired(): boolCheck whether this access token has expired and needs to be refreshed. This method compares the token's expiration time against the current time to determine if the token is still valid. Expired tokens cannot be used for API requests as they result in authentication failures.
bool — True if the token has expired and should be refreshed, false if still valid