TokenCreateResponse extends ApiResponse
Response from Authlete's /api/auth/token/create API.
Authlete's /api/auth/token/create
API returns JSON which can be mapped
to this class. The first step that a caller should take is to retrieve
the value of the action
response parameter (which can be obtained by
getAction()
method of this class) from the response.
When the value returned from getAction()
method is
TokenCreateAction::$INTERNAL_SERVER_ERROR
, it means that an error
occurred on Authlete side.
When the value returned from getAction()
method is
TokenCreateAction::$BAD_REQUEST
, it means that the request from the
caller was wrong. For example, this happens when the grantType
request
parameter is missing.
When the value returned from getAction()
method is
TokenCreateAction::$FORBIDDEN
, it means that the request from the caller
is not allowed. For example, this happens when the client application
identified by the clientId
request parameter does not belong to the
service identified by the API key used for the API call.
When the value returned from getAction()
method is
TokenCreateAction::$OK
, it means that everything was processed
successfully and an access token and optionally a refresh token were
issued. So, in short, when the value returned from getAction()
method
is TokenCreateAction::$OK
, you can retrieve the values of a new access
token and an optional refresh token from getAccessToken()
method and
getRefreshToken()
method.
Table of Contents
- copyFromArray() : mixed
- Copy the content of the given array into this object.
- copyToArray() : mixed
- Copy the content of this object into the given array.
- fromArray() : static
- Convert an array into an instance of this class.
- fromJson() : static
- Convert a JSON string into an instance of this class.
- getAccessToken() : string
- Get the value of the newly issued access token.
- getAction() : TokenCreateAction
- Get the code which indicates how the response from Authlete's /api/auth/token/create API should be interpreted.
- getClientId() : int|string
- Get the client ID associated with the newly issued access token.
- getExpiresAt() : int|string
- Get the date at which the newly issued access token will expire.
- getExpiresIn() : int|string
- Get the duration of the newly issued access token in seconds.
- getGrantType() : GrantType
- Get the grant type emulated for the newly issued access token.
- getProperties() : array<string|int, Property>
- Get properties that are associated with the newly issued access token.
- getRefreshToken() : string
- Get the value of the newly issued refresh token.
- getResultCode() : string
- Get the code of the result of an Authlete API call.
- getResultMessage() : string
- Get the message of the result of an Authlete API call.
- getScopes() : array<string|int, string>
- Get the scopes associated with the newly issued access token.
- getSubject() : string
- Get the subject (= unique identifier) of the end-user associated with the newly issued access token.
- getTokenType() : string
- Get the token type of the newly issued access token.
- setAccessToken() : TokenCreateResponse
- Set the value of the newly issued access token.
- setAction() : TokenCreateResponse
- Set the code which indicates how the response from Authlete's /api/auth/token/create API should be interpreted.
- setClientId() : TokenCreateResponse
- Set the client ID associated with the newly issued access token.
- setExpiresAt() : TokenCreateResponse
- Set the date at which the newly issued access token will expire.
- setExpiresIn() : TokenCreateResponse
- Set the duration of the newly issued access token in seconds.
- setGrantType() : TokenCreateResponse
- Set the grant type emulated for the newly issued access token.
- setProperties() : TokenCreateResponse
- Set properties that are associated with the newly issued access token.
- setRefreshToken() : TokenCreateResponse
- Set the value of the newly issued refresh token.
- setResultCode() : ApiResponse
- Set the code of the result of an Authlete API call.
- setResultMessage() : ApiResponse
- Set the message of the result of an Authlete API call.
- setScopes() : TokenCreateResponse
- Set the scopes associated with the newly issued access token.
- setSubject() : TokenCreateResponse
- Set the subject (= unique identifier) of the end-user associated with the newly issued access token.
- setTokenType() : TokenCreateResponse
- Set the token type of the newly issued access token.
- toArray() : array<string|int, mixed>
- Convert this object into an array.
- toJson() : string
- Convert this object into a JSON string.
Methods
copyFromArray()
Copy the content of the given array into this object.
public
copyFromArray(array<string|int, mixed> &$array) : mixed
Parameters
- $array : array<string|int, mixed>
Return values
mixed —copyToArray()
Copy the content of this object into the given array.
public
copyToArray(array<string|int, mixed> &$array) : mixed
Parameters
- $array : array<string|int, mixed>
Return values
mixed —fromArray()
Convert an array into an instance of this class.
public
static fromArray([array<string|int, mixed> $array = null ]) : static
This static function returns a new instance of this class.
If $array
is null
, null
is returned.
Parameters
- $array : array<string|int, mixed> = null
-
An array
Return values
static —An instance of this class.
fromJson()
Convert a JSON string into an instance of this class.
public
static fromJson(string $json) : static
This static function returns a new instance of this class.
If $json
is null
or the type of $json
is not string
,
null
is returned.
Parameters
- $json : string
-
A JSON string.
Return values
static —An instance of this class.
getAccessToken()
Get the value of the newly issued access token.
public
getAccessToken() : string
Return values
string —The access token.
getAction()
Get the code which indicates how the response from Authlete's /api/auth/token/create API should be interpreted.
public
getAction() : TokenCreateAction
Return values
TokenCreateAction —The code which indicates how the response should be interpreted.
getClientId()
Get the client ID associated with the newly issued access token.
public
getClientId() : int|string
Return values
int|string —The client ID.
getExpiresAt()
Get the date at which the newly issued access token will expire.
public
getExpiresAt() : int|string
Return values
int|string —The date at which the access token will expire. The value is expressed in milliseconds since the Unix epoch (1970-Jan-1).
getExpiresIn()
Get the duration of the newly issued access token in seconds.
public
getExpiresIn() : int|string
Return values
int|string —The duration of the access token in seconds.
getGrantType()
Get the grant type emulated for the newly issued access token.
public
getGrantType() : GrantType
Return values
GrantType —The grant type.
getProperties()
Get properties that are associated with the newly issued access token.
public
getProperties() : array<string|int, Property>
Return values
array<string|int, Property> —Properties associated with the access token.
getRefreshToken()
Get the value of the newly issued refresh token.
public
getRefreshToken() : string
This is null
when the grant type is either GrantType::$IMPLICIT
or
GrantType::$CLIENT_CREDENTIALS
or when the refresh token flow is
disabled by the service configuration.
Return values
string —The value of the newly issued refresh token.
getResultCode()
Get the code of the result of an Authlete API call.
public
getResultCode() : string
Return values
string —The result code.
getResultMessage()
Get the message of the result of an Authlete API call.
public
getResultMessage() : string
Return values
string —The result message.
getScopes()
Get the scopes associated with the newly issued access token.
public
getScopes() : array<string|int, string>
Return values
array<string|int, string> —The scopes.
getSubject()
Get the subject (= unique identifier) of the end-user associated with the newly issued access token.
public
getSubject() : string
Return values
string —The subject of the end-user. This response parameter is null
when the grant type is GrantType::$CLIENT_CREDENTIALS
.
getTokenType()
Get the token type of the newly issued access token.
public
getTokenType() : string
Return values
string —The token type.
setAccessToken()
Set the value of the newly issued access token.
public
setAccessToken(string $accessToken) : TokenCreateResponse
Parameters
- $accessToken : string
-
The access token.
Return values
TokenCreateResponse —$this
object.
setAction()
Set the code which indicates how the response from Authlete's /api/auth/token/create API should be interpreted.
public
setAction([TokenCreateAction $action = null ]) : TokenCreateResponse
Parameters
- $action : TokenCreateAction = null
-
The code which indicates how the response should be interpreted.
Return values
TokenCreateResponse —$this
object.
setClientId()
Set the client ID associated with the newly issued access token.
public
setClientId(int|string $clientId) : TokenCreateResponse
Parameters
- $clientId : int|string
-
The client ID.
Return values
TokenCreateResponse —$this
object.
setExpiresAt()
Set the date at which the newly issued access token will expire.
public
setExpiresAt(int|string $expiresAt) : TokenCreateResponse
Parameters
- $expiresAt : int|string
-
The date at which the access token will expire.
Return values
TokenCreateResponse —$this
object.
setExpiresIn()
Set the duration of the newly issued access token in seconds.
public
setExpiresIn(int|string $expiresIn) : TokenCreateResponse
Parameters
- $expiresIn : int|string
-
The duration of the access token in seconds.
Return values
TokenCreateResponse —$this
object.
setGrantType()
Set the grant type emulated for the newly issued access token.
public
setGrantType([GrantType $grantType = null ]) : TokenCreateResponse
Parameters
- $grantType : GrantType = null
-
The grant type.
Return values
TokenCreateResponse —$this
object.
setProperties()
Set properties that are associated with the newly issued access token.
public
setProperties([array<string|int, Property> $properties = null ]) : TokenCreateResponse
Parameters
- $properties : array<string|int, Property> = null
-
Properties associated with the access token.
Return values
TokenCreateResponse —$this
object.
setRefreshToken()
Set the value of the newly issued refresh token.
public
setRefreshToken(string $refreshToken) : TokenCreateResponse
Parameters
- $refreshToken : string
-
The value of the newly issued refresh token.
Return values
TokenCreateResponse —$this
object.
setResultCode()
Set the code of the result of an Authlete API call.
public
setResultCode(string $resultCode) : ApiResponse
Parameters
- $resultCode : string
-
The result code.
Return values
ApiResponse —$this
object.
setResultMessage()
Set the message of the result of an Authlete API call.
public
setResultMessage(string $resultMessage) : ApiResponse
Parameters
- $resultMessage : string
-
The result message.
Return values
ApiResponse —$this
object.
setScopes()
Set the scopes associated with the newly issued access token.
public
setScopes([array<string|int, string> $scopes = null ]) : TokenCreateResponse
Parameters
- $scopes : array<string|int, string> = null
-
The scopes.
Return values
TokenCreateResponse —$this
object.
setSubject()
Set the subject (= unique identifier) of the end-user associated with the newly issued access token.
public
setSubject(string $subject) : TokenCreateResponse
Parameters
- $subject : string
-
The subject of the end-user.
Return values
TokenCreateResponse —$this
object.
setTokenType()
Set the token type of the newly issued access token.
public
setTokenType(string $tokenType) : TokenCreateResponse
Parameters
- $tokenType : string
-
The token type.
Return values
TokenCreateResponse —$this
object.
toArray()
Convert this object into an array.
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array.
toJson()
Convert this object into a JSON string.
public
toJson(int $options) : string
Parameters
- $options : int
-
Options passed to
json_encode()
. This parameter is optional and its default value is 0.
Return values
string —A JSON string.