public class GMResponse extends ApiResponse
/api/gm API.
Authlete's /api/gm API returns JSON which can be mapped to this
class. The implementation of the grant management endpoint should retrieve
the value of "action" from the response and take the following
steps according to the value.
OK
When the value of "action" is "OK", it means that the access
token which the client application presented is valid and information about
the grant has been retrieved successfully. In this case, the implementation
of the endpoint should return an HTTP response with the status code
200 OK and the content type application/json to the client
application.
getResponseContent() returns a response in JSON format when
"action" is "OK", so a response to the client application
can be built like below.
HTTP/1.1 200 OK
Cache-Control: no-store
Pragma: no-cache
Content-Type: application/json
(The value returned from getResponseContent())
NO_CONTENT
When the value of "action" is "NO_CONTENT", it means that
the access token which the client application presented is valid and the
grant was revoked successfully. In this case, the implementation of the
endpoint should return an HTTP response with the status code
204 No Content to the client application.
UNAUTHORIZED
When the value of "action" is "UNAUTHORIZED", it means that
the grant management request includes no access token or the access token
is invalid. In this case, the implementation of the endpoint should return
an HTTP response with the status code 401 Unauthorized.
The specification does not describe details about error response format, but
in error cases, getResponseContent() returns information about the
error in the format suitable as a value for the WWW-Authenticate HTTP
header. The implementation of the endpoint may use the string when building
an error response. The following is an example.
HTTP/1.1 401 Unauthorized
WWW-Authenticate: (The value returned from getResponseContent())
Cache-Control: no-store
Pragma: no-cache
FORBIDDEN
When the value of "action" is "FORBIDDEN", it means that the
access token cannot be used to manage the grant ID. In this case, the
implementation of the endpoint should return an HTTP response with the
status code 403 Forbidden. The error response can be built like
below in the same way for the case of UNAUTHORIZED.
HTTP/1.1 403 Forbidden
WWW-Authenticate: (The value returned from getResponseContent())
Cache-Control: no-store
Pragma: no-cache
NOT_FOUND
When the value of "action" is "NOT_FOUND", it means that the
grant ID was not found. In this case, the implementation of the endpoint
should return an HTTP response with the status code 404 Not Found.
The error response can be built like below in the same way for the case of
UNAUTHORIZED.
HTTP/1.1 404 Not Found
WWW-Authenticate: (The value returned from getResponseContent())
Cache-Control: no-store
Pragma: no-cache
CALL_ERROR
When the value of "action" is "CALLER_ERROR", it means that
the API call is wrong. For example, the gmAction request parameter,
which is mandatory, is missing. The implementation of the endpoint should be
fixed. In this case, it's up to the implementation how to respond to the
client application. A simple implementation would return an HTTP response
with the status code 500 Internal Server Error like below.
HTTP/1.1 500 Internal Server Error
WWW-Authenticate: (The value returned from getResponseContent())
Cache-Control: no-store
Pragma: no-cache
AUTHLETE_ERROR
When the value of "action" is "AUTHLETE_ERROR", it means
that an error occurred on Authlete side. In this case, it's up to the
implementation how to respond to the client application. A simple
implementation would return an HTTP response with the status code
500 Internal Server Error like below.
HTTP/1.1 500 Internal Server Error
WWW-Authenticate: (The value returned from getResponseContent())
Cache-Control: no-store
Pragma: no-cache
| Modifier and Type | Class and Description |
|---|---|
static class |
GMResponse.Action
The next action the service implementation should take.
|
| Constructor and Description |
|---|
GMResponse() |
| Modifier and Type | Method and Description |
|---|---|
GMResponse.Action |
getAction()
Get the next action that the authorization server should take.
|
String |
getResponseContent()
Get the response content which can be used to build a response
to the client application.
|
GMResponse |
setAction(GMResponse.Action action)
Set the next action that the authorization server should take.
|
GMResponse |
setResponseContent(String content)
Set the response content which can be used to build a response
to the client application.
|
getResultCode, getResultMessage, setResultCode, setResultMessagepublic GMResponse.Action getAction()
public GMResponse setAction(GMResponse.Action action)
action - The next action that the authorization server should take.this object.public String getResponseContent()
public GMResponse setResponseContent(String content)
content - The content of the response to the client application.this object.Copyright © 2022. All rights reserved.