class AccessToken

This class represents the access token response returned by the authorization server.

Properties

protected string $value
protected string $secret
protected bool $authorized
protected string $expiry
protected string $type
protected string $refresh
protected string $scope
protected IdToken|null $id_token
protected string|null $response

Methods

__construct(array $accessToken = [])

Constructs a AccessToken object from an array

string
getValue()

Returns the access token string as issued by the authorization server.

string
getSecret()

Returns the access token secret.

bool
isAuthorized()

Is the OAuth token is authorized? For OAuth 2.0, this value is always true.

string
getExpiry()

Returns the expiration date time of the access token (format: %Y-%m-%d %H:%M:%S) calculated from the lifetime in seconds of the token.

string
getType()

Returns the type of token which is, typically just the string “bearer”.

string
getRefresh()

Returns the refresh token which applications can use to obtain another access token when the access token will expire.

string
getScope()

Returns the granted scope when it is different from the requested scope, such as if the user modified the scope.

IdToken|null
getIdToken()

Returns the OpenID token that the authorization server will return which encodes the user’s authentication information.

string|null
getResponse()

Returns the access token response as returned by the authorization server

setValue(string $value)

Sets the access token string as issued by the authorization server.

setSecret(string $secret)

Sets the access token secret.

setAuthorized(bool $authorized)

Determines if the OAuth token is authorized or not.

setExpiry(string $expiry)

Sets the expiration date time of the access token (format: %Y-%m-%d %H:%M:%S) calculated from the lifetime in seconds of the token.

setType(string $type)

Sets the type of token which is, typically just the string “bearer”.

setRefresh(string $refresh)

Sets the refresh token which applications can use to obtain another access token when the access token will expire.

setScope(string $scope)

Sets the granted scope when it is different from the requested scope, such as if the user modified the scope.

setIdToken(IdToken|string|null $id_token)

Sets the OpenID token that the authorization server will return which encodes the user’s authentication information.

setResponse(string $response)

Sets the access token response as returned by the authorization server

string
__toString()

Returns the access token string as issued by the authorization server.

array
toArray()

Converts the access token to array

Details

at line 77
__construct(array $accessToken = [])

Constructs a AccessToken object from an array

Parameters

array $accessToken

at line 96
string getValue()

Returns the access token string as issued by the authorization server.

Return Value

string the access token string

at line 107
string getSecret()

Returns the access token secret.

For OAuth 1.0, used for exchange, signature generation, or refreshing the access_token. Unused for other versions.

Return Value

string the access token secret

at line 117
bool isAuthorized()

Is the OAuth token is authorized? For OAuth 2.0, this value is always true.

Return Value

bool true if the OAuth token is authorized, false otherwise.

at line 127
string getExpiry()

Returns the expiration date time of the access token (format: %Y-%m-%d %H:%M:%S) calculated from the lifetime in seconds of the token.

Return Value

string the expiration date time

at line 136
string getType()

Returns the type of token which is, typically just the string “bearer”.

Return Value

string the type of token

at line 146
string getRefresh()

Returns the refresh token which applications can use to obtain another access token when the access token will expire.

Return Value

string the refresh token

at line 156
string getScope()

Returns the granted scope when it is different from the requested scope, such as if the user modified the scope.

Return Value

string the granted scope

at line 166
IdToken|null getIdToken()

Returns the OpenID token that the authorization server will return which encodes the user’s authentication information.

Return Value

IdToken|null the ID token or null if there is no ID token.

at line 175
string|null getResponse()

Returns the access token response as returned by the authorization server

Return Value

string|null the access token response

at line 186
AccessToken setValue(string $value)

Sets the access token string as issued by the authorization server.

Parameters

string $value the access token string

Return Value

AccessToken

at line 200
AccessToken setSecret(string $secret)

Sets the access token secret.

For OAuth 1.0, used for exchange, signature generation, or refreshing the access_token. Unused for other versions.

Parameters

string $secret the access token secret

Return Value

AccessToken

at line 213
AccessToken setAuthorized(bool $authorized)

Determines if the OAuth token is authorized or not.

For OAuth 2.0, this value is always true.

Parameters

bool $authorized true if authorized, false otherwise

Return Value

AccessToken

at line 226
AccessToken setExpiry(string $expiry)

Sets the expiration date time of the access token (format: %Y-%m-%d %H:%M:%S) calculated from the lifetime in seconds of the token.

Parameters

string $expiry the expiration date time of the access token

Return Value

AccessToken

at line 238
AccessToken setType(string $type)

Sets the type of token which is, typically just the string “bearer”.

Parameters

string $type the type of token

Return Value

AccessToken

at line 251
AccessToken setRefresh(string $refresh)

Sets the refresh token which applications can use to obtain another access token when the access token will expire.

Parameters

string $refresh the refresh token

Return Value

AccessToken

at line 264
AccessToken setScope(string $scope)

Sets the granted scope when it is different from the requested scope, such as if the user modified the scope.

Parameters

string $scope the granted scope

Return Value

AccessToken

at line 277
AccessToken setIdToken(IdToken|string|null $id_token)

Sets the OpenID token that the authorization server will return which encodes the user’s authentication information.

Parameters

IdToken|string|null $id_token the OpenID token

Return Value

AccessToken

at line 295
AccessToken setResponse(string $response)

Sets the access token response as returned by the authorization server

Parameters

string $response the access token response

Return Value

AccessToken

at line 306
string __toString()

Returns the access token string as issued by the authorization server.

Alias of getValue

Return Value

string the access token string

at line 315
array toArray()

Converts the access token to array

Return Value

array