Documentation

TokenIssueResponse extends ApiResponse

Response from Authlete's /api/auth/token/issue API.

Authlete's /api/auth/token/issue API returns JSON which can be mapped to this class. The token endpoint implementation should retrieve the value of the action response parameter (which can be obtained by getAction() method of this class) from the response and take the following steps according to the value.

When the value returned from getAction() method is TokenIssueAction::$INTERNAL_SERVER_ERROR, it means that the request from your system was wrong or that an error occurred in Authlete. In either case, from a viewpoint of the client application, it is an error on the server side. Therefore, the token endpoint implementation should generate a response to the client application with the HTTP status of 500 Internal Server Error.

In this case, getResponseContent() method returns a JSON string which describes the error, so it can be used as the entity body of the response. The following illustrates the response which the token endpoint implementation should generate and return to the client application.

HTTP/1.1 500 Internal Server Error
Content-Type: application/json
Cache-Control: no-store
Pragma: no-cache

(The value returned from getResponseContent())

When the value returned from getAction() method is TokenIssueAction::$OK, it means that Authlete's /api/auth/token/issue API successfully generated an access token. The HTTP status of the response returned to the client application must be 200 OK and the content type must be application/json.

In this case, getResponseContent() method returns a JSON string which contains the issued access token, so it can be used as the entity body of the response. The following illustrates the response which the token endpoint implementation should generate and return to the client application.

HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: no-store
Pragma: no-cache

(The value returned from getResponseContent())

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 newly issued access token.
getAccessTokenDuration()  : int|string
Get the duration of the access token in seconds.
getAccessTokenExpiresAt()  : int|string
Get the date at which the access token will expire.
getAccessTokenResources()  : array<string|int, string>
Get the target resources of the access token.
getAction()  : TokenIssueAction
Get the next action that the token endpoint implementation should take.
getClientId()  : int|string
Get the ID of the client application associated with the access token.
getClientIdAlias()  : string
Get the client ID alias.
getJwtAccessToken()  : string
Get the newly issued access token in JWT format.
getProperties()  : array<string|int, Property>
Get the properties associated with the access token.
getRefreshToken()  : string
Get the newly issued refresh token.
getRefreshTokenDuration()  : int|string
Get the duration of the refresh token in seconds.
getRefreshTokenExpiresAt()  : int|string
Get the date at which the refresh token will expire.
getResponseContent()  : string
Get the response content which can be used as the entity body of the response to the client application.
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 covered by the access token.
getSubject()  : string
Get the subject (= unique identifier) of the end-user (= resource owner) of the access token.
isClientIdAliasUsed()  : bool
Get the flag which indicates whether the client ID alias was used when the token request was made.
setAccessToken()  : TokenIssueResponse
Set the newly issued access token.
setAccessTokenDuration()  : TokenIssueResponse
Set the duration of the access token in seconds.
setAccessTokenExpiresAt()  : TokenIssueResponse
Set the date at which the access token will expire.
setAccessTokenResources()  : TokenIssueResponse
Set the target resources of the access token.
setAction()  : TokenIssueAction
Set the next action that the token endpoint implementation should take.
setClientId()  : TokenIssueResponse
Set the ID of the client application associated with the access token.
setClientIdAlias()  : TokenIssueResponse
Set the client ID alias.
setClientIdAliasUsed()  : TokenIssueResponse
Set the flag which indicates whether the client ID alias was used when the token request was made.
setJwtAccessToken()  : TokenIssueResponse
Set the newly issued access token in JWT format.
setProperties()  : TokenIssueResponse
Set the properties associated with the access token.
setRefreshToken()  : TokenIssueResponse
Set the newly issued refresh token.
setRefreshTokenDuration()  : TokenIssueResponse
Set the duration of the refresh token in seconds.
setRefreshTokenExpiresAt()  : TokenIssueResponse
Set the date at which the refresh token will expire.
setResponseContent()  : TokenIssueResponse
Set the response content which can be used as the entity body of the response to the client application.
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()  : TokenIssueResponse
Set the scopes covered by the access token.
setSubject()  : TokenIssueResponse
Set the subject (= unique identifier) of the end-user (= resource owner) of the 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 newly issued access token.

public getAccessToken() : string

This method returns a non-null value only when getAction() method returns TokenIssueAction::$OK.

Return values
string

The access token.

getAccessTokenDuration()

Get the duration of the access token in seconds.

public getAccessTokenDuration() : int|string
Return values
int|string

The duration of the access token in seconds.

getAccessTokenExpiresAt()

Get the date at which the access token will expire.

public getAccessTokenExpiresAt() : 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).

getAccessTokenResources()

Get the target resources of the access token.

public getAccessTokenResources() : array<string|int, string>
Tags
see
https://www.rfc-editor.org/rfc/rfc8707.html

RFC 8707 Resource Indicators for OAuth 2.0

since
1.8
Return values
array<string|int, string>

The target resources of the access token.

getClientId()

Get the ID of the client application associated with the access token.

public getClientId() : int|string
Return values
int|string

The client ID.

getClientIdAlias()

Get the client ID alias.

public getClientIdAlias() : string

If no alias is assigned to the client application, this method returns null.

Return values
string

The client ID alias.

getJwtAccessToken()

Get the newly issued access token in JWT format.

public getJwtAccessToken() : string

If the authorization server is configured to issue JWT-based access tokens (if getAccessTokenSignAlg() of Service returns a non-null value), a JWT-based access token is issued along with the original random-string one.

Tags
since
1.8
Return values
string

The newly issued access token in JWT format.

getProperties()

Get the properties associated with the access token.

public getProperties() : array<string|int, Property>
Return values
array<string|int, Property>

The properties associated with the access token.

getRefreshToken()

Get the newly issued refresh token.

public getRefreshToken() : string

This method returns a non-null value only when getAction() method returns TokenIssueAction::$OK and the service is configured to support the refresh token flow.

If "Refresh Token Continuous Use" conifiguration parameter of the service is NO (= refreshTokenKept=false), a new refresh token is issued and the old refresh token used in the refresh token flow is invalidated. On the contrary, if the configuration parameter is YES, the refresh token itself is not refreshed.

Return values
string

The refresh token.

getRefreshTokenDuration()

Get the duration of the refresh token in seconds.

public getRefreshTokenDuration() : int|string
Return values
int|string

The duration of the refresh token in seconds.

getRefreshTokenExpiresAt()

Get the date at which the refresh token will expire.

public getRefreshTokenExpiresAt() : int|string
Return values
int|string

The date at which the refresh token will expire. The value is expressed in milliseconds since the Unix epoch (1970-Jan-1).

getResponseContent()

Get the response content which can be used as the entity body of the response to the client application.

public getResponseContent() : string
Return values
string

The response content.

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 covered by the access token.

public getScopes() : array<string|int, string>
Return values
array<string|int, string>

The scopes covered by the access token.

getSubject()

Get the subject (= unique identifier) of the end-user (= resource owner) of the access token.

public getSubject() : string
Return values
string

The subject of the end-user.

isClientIdAliasUsed()

Get the flag which indicates whether the client ID alias was used when the token request was made.

public isClientIdAliasUsed() : bool
Return values
bool

true if the client ID alias was used in the token request.

setAccessTokenDuration()

Set the duration of the access token in seconds.

public setAccessTokenDuration(int|string $duration) : TokenIssueResponse
Parameters
$duration : int|string

The duration of the access token in seconds.

Return values
TokenIssueResponse

$this object.

setAccessTokenExpiresAt()

Set the date at which the access token will expire.

public setAccessTokenExpiresAt(int|string $expiresAt) : TokenIssueResponse
Parameters
$expiresAt : int|string

The date at which the access token will expire. The value should be expressed in milliseconds since the Unix epoch (1970-Jan-1).

Return values
TokenIssueResponse

$this object.

setClientIdAliasUsed()

Set the flag which indicates whether the client ID alias was used when the token request was made.

public setClientIdAliasUsed(bool $used) : TokenIssueResponse
Parameters
$used : bool

true to indicate that the client ID alias was used in the token request.

Return values
TokenIssueResponse

$this object.

setJwtAccessToken()

Set the newly issued access token in JWT format.

public setJwtAccessToken(string $jwtAccessToken) : TokenIssueResponse

If the authorization server is configured to issue JWT-based access tokens (if getAccessTokenSignAlg() of Service returns a non-null value), a JWT-based access token is issued along with the original random-string one.

Parameters
$jwtAccessToken : string

The newly issued access token in JWT format.

Tags
since
1.8
Return values
TokenIssueResponse

$this object.

setRefreshTokenDuration()

Set the duration of the refresh token in seconds.

public setRefreshTokenDuration(int|string $duration) : TokenIssueResponse
Parameters
$duration : int|string

The duration of the refresh token in seconds.

Return values
TokenIssueResponse

$this object.

setRefreshTokenExpiresAt()

Set the date at which the refresh token will expire.

public setRefreshTokenExpiresAt(int|string $expiresAt) : TokenIssueResponse
Parameters
$expiresAt : int|string

The date at which the refresh token will expire. The value should be expressed in milliseconds since the Unix epoch (1970-Jan-1).

Return values
TokenIssueResponse

$this object.

setResponseContent()

Set the response content which can be used as the entity body of the response to the client application.

public setResponseContent(string $responseContent) : TokenIssueResponse
Parameters
$responseContent : string

The response content.

Return values
TokenIssueResponse

$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 covered by the access token.

public setScopes([array<string|int, string> $scopes = null ]) : TokenIssueResponse
Parameters
$scopes : array<string|int, string> = null

The scopes covered by the access token.

Return values
TokenIssueResponse

$this object.

setSubject()

Set the subject (= unique identifier) of the end-user (= resource owner) of the access token.

public setSubject(string $subject) : TokenIssueResponse
Parameters
$subject : string

The subject of the end-user.

Return values
TokenIssueResponse

$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.

Search results