Documentation

UserInfoIssueResponse extends ApiResponse

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

Authlete's /api/auth/userinfo/issue API returns JSON which can be mapped to this class. The userInfo 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 UserInfoIssueAction::$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 userinfo 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 string which describes the error in the format of RFC 6750 (OAuth 2.0 Bearer Token Usage), so the userinfo endpoint implementation of your system can use the string returned from the method as the value of the WWW-Authenticate header. The following is an example response which complies with RFC 6750. Note that OpenID Connect Core 1.0 requires that an error response from the userinfo endpoint comply with RFC 6750. See 5.3.3. UserInfo Error Response for details.

HTTP/1.1 500 Internal Server Error
WWW-Authenticate: (The value returned from getResponseContent())
Cache-Control: no-store
Pragram: no-cache

When the value returned from getAction() method is UserInfoIssueAction::$BAD_REQUEST, it means that the request from the client application does not contain an access token (= the request from your system to Authlete does not contain the token request parameter).

In this case, getResponseContent() method returns a string which describes the error in the format of RFC 6750 (OAuth 2.0 Bearer Token Usage), so the userinfo endpoint implementation can use the string returned from the method as the value of the WWW-Authenticate header. The following is an example response from the userinfo endpoint to the client application.

HTTP/1.1 400 Bad Request
WWW-Authenticate: (The value returned from getResponseContent())
Cache-Control: no-store
Pragma: no-cache

When the value returned from getAction() method is UserInfoIssueAction::$UNAUTHORIZED, it means that the access token does not exist, has expired, or is not associated with any subject (= any end-user).

In this case, getResponseContent() method returns a string which describes the error in the format of RFC 6750 (OAuth 2.0 Bearer Token Usage), so the userinfo endpoint implementation can use the string returned from the method as the value of the WWW-Authenticate header. The following is an example response from the userinfo endpoint to the client application.

HTTP/1.1 401 Unauthorized
WWW-Authenticate: (The value returned from getResponseContent())
Cache-Control: no-store
Pragma: no-cache

When the value returned from getAction() method is UserInfoIssueAction::$FORBIDDEN, it means that the access token does not have the openid scope.

In this case, getResponseContent() method returns a string which describes the error in the format of RFC 6750 (OAuth 2.0 Bearer Token Usage), so the userinfo endpoint implementation can use the string returned from the method as the value of the WWW-Authenticate header. The following is an example response from the userinfo endpoint to the client application.

HTTP/1.1 403 Forbidden
WWW-Authenticate: (The value returned from getResponseContent())
Cache-Control: no-store
Pragma: no-cache

When the value returned from getAction() method is UserInfoIssueAction::$JSON, it means that the access token which the client application presented is valid and a userinfo response was successfully generated in the format of JSON.

The userinfo endpoint of your system is expected to generate a response to the client application. The content type of the response must be application/json.

In this case, getResponseContent() method returns a userinfo response in JSON format, so a response to the client can be built like below.

HTTP/1.1 200 OK
Cache-Control: no-store
Pragma: no-cache
Content-Type: application/json;charset=UTF-8

(The value returned from getResponseContent())

When the value returned from getAction() method is UserInfoIssueAction::$JWT, it means that the access token which the client application presented is valid and a userinfo response was successfully generated in the format of JWT (RFC 7519).

The userinfo endpoint of your system is expected to generate a response to the client application. The content type of the response must be application/jwt.

In this case, the getResponseContent() method returns a userinfo response in JWT format, so a response to the client can be built like below.

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

(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.
getAction()  : UserInfoAction
Get the next action that the userinfo endpoint should take.
getResponseContent()  : string
Get the response content which can be used as the entity body of the response returned from the userinfo endpoint implementation 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.
setAction()  : UserInfoIssueResponse
Set the next action that the userinfo endpoint should take.
setResponseContent()  : UserInfoIssueResponse
Set the response content which can be used as the entity body of the response returned from the userinfo endpoint implementation 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.

getResponseContent()

Get the response content which can be used as the entity body of the response returned from the userinfo endpoint implementation 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.

setResponseContent()

Set the response content which can be used as the entity body of the response returned from the userinfo endpoint implementation to the client application.

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

The response content.

Return values
UserInfoIssueResponse

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

Search results