Documentation

DeviceAuthorizationResponse extends ApiResponse

Response from Authlete's /api/device/authorization API.

Authlete's /api/device/authorization 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 of this class) from the response and take the following steps according to the value.


When the value returned from getAction() method is DeviceAuthorizationAction::$OK, it means that the device authorization request from the client application is valid.

The authorization server implementation should generate a response to the client application with 200 OK and application/json.

The getResponseContent() method returns a JSON string which 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: application/json
Cache-Control: no-store
Pragma: no-cache

(The value returned from getResponseContent())

When the value returned from getAction() method is DeviceAuthorizationAction::$BAD_REQUEST, it means that the device authorization request from the client application was wrong.

The authorization server implementation should generate a response to the client application with 400 Bad Request and application/json.

The 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 DeviceAuthorizationAction::$UNAUTHORIZED, it means that client authentication of the device authorization request failed.

The authorization server implementation should generate a response to the client application with 401 Unauthorized and application/json.

The 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 401 Unauthorized
Content-Type: application/json
Cache-Control: no-store
Pragma: no-cache

(The value returned from getResponseContent())

When the value returned from getAction() method is DeviceAuthorizationAction::$INTERNAL_SERVER_ERROR, it means that the API call from the authorization server implementation 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 authorization server implementation should generate a response to the client application with 500 Internal Server Error and application/json.

The 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())
Tags
since
1.8

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.
getAcrs()  : array<string|int, string>
Get the list of ACR values requestsed by the device authorization request.
getAction()  : DeviceAuthorizationAction
Get the next action that the device authorization endpoint should take.
getClaimNames()  : array<string|int, string>
Get the names of the claims which were requested indirectly via some special scopes. See [5.4. Requesting Claims using Scope Values](https://openid.net/specs/openid-connect-core-1_0.html#ScopeClaims) in [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0.html#ScopeClaims) for details.
getClientId()  : int|string
Get the ID of the client application that has made the device authorization request.
getClientIdAlias()  : string
Get the client ID alias of the client application that has made the device authorization request.
getClientName()  : string
Get the name of the client application that has made the device authorization request.
getDeviceCode()  : string
Get the device verification code. This corresponds to the `device_code` property in the response to the client.
getExpiresIn()  : int|string
Get the duration of the issued device verification code and end-user verification code in seconds. This corresponds to the `expires_in` property in the response to the client.
getInterval()  : int
Get the minimum amount of time in seconds that the client must wait for between polling requests to the token endpoint. This corresponds to the `interval` property in the response to the client.
getResources()  : array<string|int, string>
Get the resources specified by the `resource` request parameters.
getResponseContent()  : string
Get the content that 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.
getScopes()  : array<string|int, Scope>
Get the scopes requested by the device authorization request.
getUserCode()  : string
Get the end-user verification code. This corresponds to the `user_code` property in the response to the client.
getVerificationUri()  : string
Get the end-user verification URI. This corresponds to the `verification_uri` property in the response to the client.
getVerificationUriComplete()  : string
Get the end-user verification URI that includes the end-user verification code. This corresponds to the `verification_uri_complete` property in the response to the client.
getWarnings()  : array<string|int, string>
Get the warnings raised during processing the device authorization request.
isClientIdAliasUsed()  : bool
Get the flag which indicates whether the client ID alias was used in the device authorization request.
setAcrs()  : DeviceAuthorizationResponse
Set the list of ACR values requestsed by the device authorization request.
setAction()  : DeviceAuthorizationResponse
Set the next action that the device authorization endpoint should take.
setClaimNames()  : DeviceAuthorizationResponse
Set the names of the claims which were requested indirectly via some special scopes.
setClientId()  : DeviceAuthorizationResponse
Set the ID of the client application that has made the device authorization request.
setClientIdAlias()  : DeviceAuthorizationResponse
Set the client ID alias of the client application that has made the device authorization request.
setClientIdAliasUsed()  : DeviceAuthorizationResponse
Set the flag which indicates whether the client ID alias was used in the device authorization request.
setClientName()  : DeviceAuthorizationResponse
Set the name of the client application that has made the device authorization request.
setDeviceCode()  : DeviceAuthorizationResponse
Set the device verification code. This corresponds to the `device_code` property in the response to the client.
setExpiresIn()  : DeviceAuthorizationResponse
Set the duration of the issued device verification code and end-user verification code in seconds. This corresponds to the `expires_in` property in the response to the client.
setInterval()  : DeviceAuthorizationResponse
Set the minimum amount of time in seconds that the client must wait for between polling requests to the token endpoint. This corresponds to the `interval` property in the response to the client.
setResources()  : DeviceAuthorizationResponse
Set the resources specified by the `resource` request parameters.
setResponseContent()  : DeviceAuthorizationResponse
Set the content that 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.
setScopes()  : DeviceAuthorizationResponse
Set the scopes requested by the device authorization request.
setUserCode()  : DeviceAuthorizationResponse
Set the end-user verification code. This corresponds to the `user_code` property in the response to the client.
setVerificationUri()  : DeviceAuthorizationResponse
Set the end-user verification URI. This corresponds to the `verification_uri` property in the response to the client.
setVerificationUriComplete()  : DeviceAuthorizationResponse
Set the end-user verification URI that includes the end-user verification code. This corresponds to the `verification_uri_complete` property in the response to the client.
setWarnings()  : DeviceAuthorizationResponse
Set the warnings raised during processing the device authorization request.
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.

getAcrs()

Get the list of ACR values requestsed by the device authorization request.

public getAcrs() : array<string|int, string>

Basically, this method returns the value of the acr_values request parameter in the device authorization request. However, because unsupported ACR values are dropped on Authlete side, if the acr_values request parameter contains unrecognized ACR values, the list returned by this method becomes different from the value of the acr_values request parameter.

If the request does not include the acr_values request parameter, the value of the default_acr_values client metadata is used.

Return values
array<string|int, string>

The list of requested ACR values.

getClaimNames()

Get the names of the claims which were requested indirectly via some special scopes. See [5.4. Requesting Claims using Scope Values](https://openid.net/specs/openid-connect-core-1_0.html#ScopeClaims) in [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0.html#ScopeClaims) for details.

public getClaimNames() : array<string|int, string>

This method always returns null if the scope request parameter of the device authorization request does not include the openid scope even if special scopes (such as profile) are included in the request (unless the openid scope is included in the default set of scopes which is used when the scope request parameter is omitted).

Return values
array<string|int, string>

The names of the requested claims.

getClientId()

Get the ID of the client application that has made the device authorization request.

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

The client ID.

getClientIdAlias()

Get the client ID alias of the client application that has made the device authorization request.

public getClientIdAlias() : string
Return values
string

The client ID alias.

getClientName()

Get the name of the client application that has made the device authorization request.

public getClientName() : string
Return values
string

The name of the client application.

getDeviceCode()

Get the device verification code. This corresponds to the `device_code` property in the response to the client.

public getDeviceCode() : string
Return values
string

The device verification code.

getExpiresIn()

Get the duration of the issued device verification code and end-user verification code in seconds. This corresponds to the `expires_in` property in the response to the client.

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

The duration of the issued device verification code and end-user verification code in seconds.

getInterval()

Get the minimum amount of time in seconds that the client must wait for between polling requests to the token endpoint. This corresponds to the `interval` property in the response to the client.

public getInterval() : int
Return values
int

The minimum amount of time in seconds between polling requests.

getResponseContent()

Get the content that can be used to generate a 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 requested by the device authorization request.

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

Basically, this method returns the value of the scope request parameter in the device authorization request. However, because unregistered scopes are dropped on Authlete side, if the scope request parameter contains unknown scopes, the list returned by this method becomes different from the value of the scope request parameter.

Note that Scope.getDescription() method and Scope.getDescriptions() method of each element (Scope instance) in the array returned from this method always return null even if descriptions of the scopes are registered.

Return values
array<string|int, Scope>

The requested scopes.

getUserCode()

Get the end-user verification code. This corresponds to the `user_code` property in the response to the client.

public getUserCode() : string
Return values
string

The end-user verification code.

getVerificationUri()

Get the end-user verification URI. This corresponds to the `verification_uri` property in the response to the client.

public getVerificationUri() : string
Return values
string

The end-user verification URI.

getVerificationUriComplete()

Get the end-user verification URI that includes the end-user verification code. This corresponds to the `verification_uri_complete` property in the response to the client.

public getVerificationUriComplete() : string
Return values
string

The end-user verification URI that includes the end-user verification code.

getWarnings()

Get the warnings raised during processing the device authorization request.

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

Warnings. This may be null.

isClientIdAliasUsed()

Get the flag which indicates whether the client ID alias was used in the device authorization request.

public isClientIdAliasUsed() : bool
Return values
bool

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

setExpiresIn()

Set the duration of the issued device verification code and end-user verification code in seconds. This corresponds to the `expires_in` property in the response to the client.

public setExpiresIn(int|string $expiresIn) : DeviceAuthorizationResponse
Parameters
$expiresIn : int|string

The duration of the issued device verification code and end-user verification code in seconds.

Return values
DeviceAuthorizationResponse

$this object.

setInterval()

Set the minimum amount of time in seconds that the client must wait for between polling requests to the token endpoint. This corresponds to the `interval` property in the response to the client.

public setInterval(int $interval) : DeviceAuthorizationResponse
Parameters
$interval : int

The minimum amount of time in seconds between polling requests.

Return values
DeviceAuthorizationResponse

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

setVerificationUriComplete()

Set the end-user verification URI that includes the end-user verification code. This corresponds to the `verification_uri_complete` property in the response to the client.

public setVerificationUriComplete(string $uri) : DeviceAuthorizationResponse
Parameters
$uri : string

The end-user verification URI that includes the end-user verification code.

Return values
DeviceAuthorizationResponse

$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