AuthorizationIssueResponse extends ApiResponse
Response from Authlete's /api/auth/authorization/issue API.
Authlete's /api/auth/authorization/issue
API returns JSON which can be
mapped to this class. The authorization server implementation should
retrieve the value of the action
response parameter (which can be
obtained by getAction()
method) from the response and take the following
steps according to the value.
When the value returned from getAction()
method is
AuthorizationIssueAction::$INTERNAL_SERVER_ERROR
, it means that the
request from the authorization server implementation was wrong or that an
error ocurred in Authlete. In either case, from a viewpoint of the client
application, it is an error on the server side. Therefore, the
authorization server 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 authorization server
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
AuthorizationIssueAction::$BAD_REQUEST
, it means that the ticket is no
longer valid (deleted or expired) and that the reason of the invalidity
was probably due to the end-user's too-delayed response to the
authorization UI.
The HTTP status of the response returned to the client application should
be 400 Bad Request
and the content type should be application/json
although OAuth 2.0 specification does not mention the format of the error
response for this case.
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 authorization server
implementation should generate and return to the client application.
HTTP/1.1 400 Bad Request
Content-Type: application/json
Cache-Control: no-store
Pragma: no-cache
(The value returned from getResponseContent())
When the value returned from getAction()
method is
AuthorizationIssueAction::$LOCATION
, it means that the response to the
client application should be 302 Found
with a Location
header.
In this case, getResponseContent()
method returns a redirect URI which
contains (1) an authorization code, an ID token and/or an access token
(on success) or (2) an error code (on failure), so it can be used as the
value of Location
header. The following illustrates the response which
the authorization server implementation should generate and return to the
client application.
HTTP/1.1 302 Found
Location: (The value returned from getResponseContent())
Cache-Control: no-store
Pragma: no-cache
When the value returned from getAction()
method is
AuthorizationIssueAction::$FORM
, it means that the response to the
client application should be 200 OK
with an HTML which triggers
redirection by JavaScript. This happens when the authorization request
from the client application contains response_mode=form_post
.
In this case, getResponseContent()
method returns an HTML which
satisfies the requirements of response_mode=form_post
, so it can be
used as the entity body of the response. The following illustrates the
response which the authorization server implementation should generate
and return to the client application.
HTTP/1.1 200 OK
Content-Type: text/html;charset=UTF-8
Cache-Control: no-store
Pragma: no-store
(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 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.
- getAction() : AuthorizationIssueAction
- Get the next action that the authorization server implementation should take.
- getAuthorizationCode() : string
- Get the newly issued authorization code.
- getIdToken() : string
- Get the newly issued ID token.
- getJwtAccessToken() : string
- Get the newly issued access token in JWT format.
- getResponseContent() : string
- Get the response content which can be used to generate a 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.
- setAccessToken() : AuthorizationIssueResponse
- Set the access token.
- setAccessTokenDuration() : AuthorizationIssueResponse
- Set the duration of the access token in seconds.
- setAccessTokenExpiresAt() : AuthorizationIssueResponse
- Set the date at which the access token will expire.
- setAction() : AuthorizationIssueResponse
- Set the next action that the authorization server implementation should take.
- setAuthorizationCode() : AuthorizationIssueResponse
- Set the newly issued authorization code.
- setIdToken() : AuthorizationIssueResponse
- Set the newly issued ID token.
- setJwtAccessToken() : AuthorizationIssueResponse
- Set the newly issued access token in JWT format.
- setResponseContent() : AuthorizationIssueResponse
- Set the response content which can be used to generate a 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.
- 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 access token.
public
getAccessToken() : string
An access token is issued when the response_type
request parameter
of the authorization request includes token
.
If the service is configured to issue JWT-based access tokens, a
JWT-based access token is issued additionally. In the case,
getJwtAccessToken()
returns the JWT-based access token.
Tags
Return values
string —The newly issued access token.
getAccessTokenDuration()
Get the duration of the access token in seconds.
public
getAccessTokenDuration() : int|string
Tags
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
Tags
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).
getAction()
Get the next action that the authorization server implementation should take.
public
getAction() : AuthorizationIssueAction
Return values
AuthorizationIssueAction —The next action that the authorization server implementation should take.
getAuthorizationCode()
Get the newly issued authorization code.
public
getAuthorizationCode() : string
An authorization code is issued when the response_type
request
parameter of the authorization request includes code
.
Tags
Return values
string —The newly issued authorization code.
getIdToken()
Get the newly issued ID token.
public
getIdToken() : string
An ID token is issued when the response_type
request parameter of the
authorization request includes id_token
.
Tags
Return values
string —The newly issued ID token.
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 Service.getAccessTokenSignAlg()
returns a non-null
value), a JWT-based access token is issued along with the original
random-string one.
Tags
Return values
string —The newly issued access token in JWT format.
getResponseContent()
Get the response content which can be used to generate a response to the client application.
public
getResponseContent() : string
The format of the value varies depending on the value returned from
getAction()
method.
Return values
string —The response content which can be used to generate a response to the client application.
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.
setAccessToken()
Set the access token.
public
setAccessToken(string $accessToken) : AuthorizationIssueResponse
Parameters
- $accessToken : string
-
The access token.
Tags
Return values
AuthorizationIssueResponse —$this
object.
setAccessTokenDuration()
Set the duration of the access token in seconds.
public
setAccessTokenDuration(int|string $duration) : AuthorizationIssueResponse
Parameters
- $duration : int|string
-
The duration of the access token in seconds.
Tags
Return values
AuthorizationIssueResponse —$this
object.
setAccessTokenExpiresAt()
Set the date at which the access token will expire.
public
setAccessTokenExpiresAt(int|string $expiresAt) : AuthorizationIssueResponse
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).
Tags
Return values
AuthorizationIssueResponse —$this
object.
setAction()
Set the next action that the authorization server implementation should take.
public
setAction([AuthorizationIssueAction $action = null ]) : AuthorizationIssueResponse
Parameters
- $action : AuthorizationIssueAction = null
-
The next action that the authorization server implementation should take.
Return values
AuthorizationIssueResponse —$this
object.
setAuthorizationCode()
Set the newly issued authorization code.
public
setAuthorizationCode(string $code) : AuthorizationIssueResponse
Parameters
- $code : string
-
The newly issued authorization code.
Tags
Return values
AuthorizationIssueResponse —$this
object.
setIdToken()
Set the newly issued ID token.
public
setIdToken(string $idToken) : AuthorizationIssueResponse
Parameters
- $idToken : string
-
The newly issued ID token.
Tags
Return values
AuthorizationIssueResponse —$this
object.
setJwtAccessToken()
Set the newly issued access token in JWT format.
public
setJwtAccessToken(string $jwtAccessToken) : AuthorizationIssueResponse
Parameters
- $jwtAccessToken : string
-
The newly issued access token in JWT format.
Tags
Return values
AuthorizationIssueResponse —$this
object.
setResponseContent()
Set the response content which can be used to generate a response to the client application.
public
setResponseContent(string $responseContent) : AuthorizationIssueResponse
Parameters
- $responseContent : string
-
The response content which can be used to generate a response to the client application.
Return values
AuthorizationIssueResponse —$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.
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.