public class TokenIssueResponse extends ApiResponse
/auth/token/issue endpoint.
Authlete's /auth/token/issue endpoint returns JSON which can
be mapped to this class. The service implementation should retrieve
the value of "action" from the response and take the following
steps according to the value.
INTERNAL_SERVER_ERROR
When the value of "action" is "INTERNAL_SERVER_ERROR",
it means that the request from the service implementation was wrong or
that an error occurred in Authlete.
In either case, from the viewpoint of the client application, it is an
error on the server side. Therefore, the service implementation should
generate a response to the client application with the HTTP status of
"500 Internal Server Error".
getResponseContent() 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 service 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())
OK
When the value of "action" is "OK", it means that
Authlete's /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".
getResponseContent() returns a JSON string which contains
an access token, so it can be used as the entity body of the response.
The following illustrates the response which the service 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())
| Modifier and Type | Class and Description |
|---|---|
static class |
TokenIssueResponse.Action
The next action that the service implementation should take.
|
| Constructor and Description |
|---|
TokenIssueResponse() |
| Modifier and Type | Method and Description |
|---|---|
String |
getAccessToken()
Get the newly issued access token.
|
long |
getAccessTokenDuration()
Get the duration of the access token in seconds.
|
long |
getAccessTokenExpiresAt()
Get the date in milliseconds since the Unix epoch (1970-01-01)
at which the access token will expire.
|
TokenIssueResponse.Action |
getAction()
Get the next action that the service implementation should take.
|
long |
getClientId()
Get the client ID.
|
String |
getClientIdAlias()
Get the client ID alias.
|
String |
getJwtAccessToken()
Get the newly issued access token in JWT format.
|
Property[] |
getProperties()
Get the extra properties associated with the access token.
|
String |
getRefreshToken()
Get the refresh token.
|
long |
getRefreshTokenDuration()
Get the duration of the refresh token in seconds.
|
long |
getRefreshTokenExpiresAt()
Get the date in milliseconds since the Unix epoch (1970-01-01)
at which the refresh token will expire.
|
String |
getResponseContent()
Get the response content which can be used as the entity body
of the response returned to the client application.
|
String[] |
getScopes()
Get the scopes covered by the access token.
|
String |
getSubject()
Get the subject (= resource owner's ID) of the access token.
|
boolean |
isClientIdAliasUsed()
Get the flag which indicates whether the client ID alias was used
when the token request was made.
|
void |
setAccessToken(String accessToken)
Set the newly issued access token.
|
void |
setAccessTokenDuration(long duration)
Set the duration of the access token in seconds.
|
void |
setAccessTokenExpiresAt(long expiresAt)
Set the date in milliseconds since the Unix epoch (1970-01-01)
at which the access token will expire.
|
void |
setAction(TokenIssueResponse.Action action)
Set the next action that the service implementation should take.
|
void |
setClientId(long clientId)
Set the client ID.
|
void |
setClientIdAlias(String alias)
Set the client ID alias.
|
void |
setClientIdAliasUsed(boolean used)
Set the flag which indicates whether the client ID alias was used
when the token request was made.
|
void |
setJwtAccessToken(String jwtAccessToken)
Set the newly issued access token in JWT format.
|
void |
setProperties(Property[] properties)
Set the extra properties associated with the access token.
|
void |
setRefreshToken(String refreshToken)
Set the refresh token.
|
void |
setRefreshTokenDuration(long duration)
Set the duration of the refresh token in seconds.
|
void |
setRefreshTokenExpiresAt(long expiresAt)
Set the date in milliseconds since the Unix epoch (1970-01-01)
at which the refresh token will expire.
|
void |
setResponseContent(String responseContent)
Set the response content which can be used as the entity body
of the response returned to the client application.
|
void |
setScopes(String[] scopes)
Set the scopes covered by the access token.
|
void |
setSubject(String subject)
Set the subject (= resource owner's ID).
|
String |
summarize()
Get the summary of this instance.
|
getResultCode, getResultMessage, setResultCode, setResultMessagepublic TokenIssueResponse.Action getAction()
public void setAction(TokenIssueResponse.Action action)
public String getResponseContent()
public void setResponseContent(String responseContent)
public String summarize()
public String getAccessToken()
getAction() returns TokenIssueResponse.Action.OK.
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.
getJwtAccessToken()public void setAccessToken(String accessToken)
accessToken - The newly issued access token.public long getAccessTokenExpiresAt()
public void setAccessTokenExpiresAt(long expiresAt)
expiresAt - The expiration date in milliseconds since the Unix epoch
(1970-01-01) at which the access token will expire.public long getAccessTokenDuration()
public void setAccessTokenDuration(long duration)
duration - Duration in seconds.public String getRefreshToken()
getAction() returns TokenIssueResponse.Action.OK and the service supports
the refresh token
flow.
If "Refresh Token Continuous Use" configuration parameter 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.
public void setRefreshToken(String refreshToken)
refreshToken - The refresh token.public long getRefreshTokenExpiresAt()
public void setRefreshTokenExpiresAt(long expiresAt)
expiresAt - The expiration date in milliseconds since the Unix epoch
(1970-01-01) at which the refresh token will expire.
If the refresh token is null, this method returns 0.public long getRefreshTokenDuration()
public void setRefreshTokenDuration(long duration)
duration - Duration in seconds.public long getClientId()
public void setClientId(long clientId)
public String getClientIdAlias()
If the client did not have an alias, this method returns
null.
public void setClientIdAlias(String alias)
alias - The client ID alias.public boolean isClientIdAliasUsed()
true if the client ID alias was used when the token
request was made.public void setClientIdAliasUsed(boolean used)
used - true if the client ID alias was used when the token
request was made.public String getSubject()
public void setSubject(String subject)
public String[] getScopes()
public void setScopes(String[] scopes)
public Property[] getProperties()
null when no extra property is
associated with the issued access token.public void setProperties(Property[] properties)
properties - Extra properties.public String getJwtAccessToken()
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.
Regarding the detailed format of the JWT-based access token, see the
description of the Service class.
getAccessToken()public void setJwtAccessToken(String jwtAccessToken)
jwtAccessToken - The newly issued access token in JWT format.Copyright © 2019. All rights reserved.