Class TokenCreateResponse
- java.lang.Object
-
- com.authlete.common.dto.ApiResponse
-
- com.authlete.common.dto.TokenCreateResponse
-
- All Implemented Interfaces:
Serializable
public class TokenCreateResponse extends ApiResponse
Response from Authlete's/auth/token/create
API.Authlete's
/auth/token/create
API returns JSON which can be mapped to this class. The first step that a caller should take is to retrieve the value ofaction
parameter from the response. The list below shows possible values ofaction
parameter and their meanings.INTERNAL_SERVER_ERROR
-
When the value of
action
parameter is"INTERNAL_SERVER_ERROR"
, it means that an error occurred on Authlete side. BAD_REQUEST
-
When the value of
action
parameter is"BAD_REQUEST"
, it means that the request from the caller was wrong. For example, this happens when thegrantType
request parameter is not specified. FORBIDDEN
-
When the value of
action
parameter is"FORBIDDEN"
, it means that the request from the caller is not allowed. For example, this happens when the client application identified by theclientId
request parameter does not belong to the service identified by the API key used for the API call. OK
-
When the value of
action
parameter is"OK"
, it means that everything was processed successfully and an access token and optionally a refresh token were issued.
So, in short, when the value of
action
parameter in the response from Authlete's/auth/token/create
API is"OK"
, you can find a new access token and optionally a new refresh token inaccessToken
parameter andrefreshToken
parameter.- Since:
- 1.13
- Author:
- Takahiko Kawasaki
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TokenCreateResponse.Action
The code indicating how the response should be interpreted.
-
Constructor Summary
Constructors Constructor Description TokenCreateResponse()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getAccessToken()
Get the newly issued access token.TokenCreateResponse.Action
getAction()
Get the code indicating how the response should be interpreted.AuthzDetails
getAuthorizationDetails()
Get the authorization details associated with the access token.long
getClientId()
Get the client ID associated with the newly issued access token.String
getClientIdentifier()
Get the client Identifier associated with the newly issued access token.long
getExpiresAt()
Get the date at which the newly issued access token will expire.long
getExpiresIn()
Get the duration of the newly issued access token in seconds.GrantType
getGrantType()
Get thegrant type
for the newly issued access token.String
getJwtAccessToken()
Get the newly issued access token in JWT format.Property[]
getProperties()
Get the properties associated with the access token.String
getRefreshToken()
Get the newly issued refresh token.String[]
getRefreshTokenScopes()
Get the scopes associated with the refresh token.String[]
getScopes()
Get the scopes associated with the newly issued access token.String
getSubject()
Get the subject (= unique identifier) of the user associated with the newly issued access token.String
getTokenId()
Get the unique token identifier.String
getTokenType()
Get the token type of the access token.boolean
isForExternalAttachment()
Get the flag which indicates whether the access token is for an external attachment.TokenCreateResponse
setAccessToken(String accessToken)
Set the newly issued access token.TokenCreateResponse
setAction(TokenCreateResponse.Action action)
Set the code indicating how the response should be interpreted.TokenCreateResponse
setAuthorizationDetails(AuthzDetails authorizationDetails)
Set the authorization details associated with the access token.TokenCreateResponse
setClientId(long clientId)
Set the client ID associated with the newly issued access token.TokenCreateResponse
setClientIdentifier(String clientIdentifier)
Set the client Identifier associated with the newly issued access token.TokenCreateResponse
setExpiresAt(long expiresAt)
Set the date at which the newly issued access token will expire.TokenCreateResponse
setExpiresIn(long expiresIn)
Set the duration of the newly issued access token in seconds.TokenCreateResponse
setForExternalAttachment(boolean forExternalAttachment)
Set the flag which indicates whether the access token is for an external attachment.TokenCreateResponse
setGrantType(GrantType grantType)
Set thegrant type
for the newly issued access token.TokenCreateResponse
setJwtAccessToken(String jwtAccessToken)
Set the newly issued access token in JWT format.TokenCreateResponse
setProperties(Property[] properties)
Set the properties associated with the access token.TokenCreateResponse
setRefreshToken(String refreshToken)
Set the newly issued refresh token.TokenCreateResponse
setRefreshTokenScopes(String[] refreshTokenScopes)
Set the scopes associated with the refresh token.TokenCreateResponse
setScopes(String[] scopes)
Set the scopes associated with the newly issued access token.TokenCreateResponse
setSubject(String subject)
Set the subject (= unique identifier) of the user associated with the newly issued access token.TokenCreateResponse
setTokenId(String tokenId)
Set the unique token identifier.TokenCreateResponse
setTokenType(String tokenType)
Set the token type of the access token.String
summarize()
Get the summary of this instance.-
Methods inherited from class com.authlete.common.dto.ApiResponse
getResultCode, getResultMessage, setResultCode, setResultMessage
-
-
-
-
Method Detail
-
getAction
public TokenCreateResponse.Action getAction()
Get the code indicating how the response should be interpreted. See thedescription
of this class for details.- Returns:
- The code indicating how the response should be interpreted.
-
setAction
public TokenCreateResponse setAction(TokenCreateResponse.Action action)
Set the code indicating how the response should be interpreted. See thedescription
of this class for details.- Parameters:
action
- The code indicating how the response should be interpreted.- Returns:
this
object.
-
getGrantType
public GrantType getGrantType()
Get thegrant type
for the newly issued access token.- Returns:
- Grant type.
-
setGrantType
public TokenCreateResponse setGrantType(GrantType grantType)
Set thegrant type
for the newly issued access token.- Parameters:
grantType
- Grant type.- Returns:
this
object.
-
getClientId
public long getClientId()
Get the client ID associated with the newly issued access token.- Returns:
- Client ID.
-
setClientId
public TokenCreateResponse setClientId(long clientId)
Set the client ID associated with the newly issued access token.- Parameters:
clientId
- Client ID.- Returns:
this
object.
-
getSubject
public String getSubject()
Get the subject (= unique identifier) of the user associated with the newly issued access token. This value isnull
when thegrant type
obtained bygetGrantType()
isCLIENT_CREDENTIALS
.- Returns:
- The subject of the user.
-
setSubject
public TokenCreateResponse setSubject(String subject)
Set the subject (= unique identifier) of the user associated with the newly issued access token.- Parameters:
subject
- The subject of the user.- Returns:
this
object.
-
getScopes
public String[] getScopes()
Get the scopes associated with the newly issued access token.- Returns:
- Scopes. May be
null
.
-
setScopes
public TokenCreateResponse setScopes(String[] scopes)
Set the scopes associated with the newly issued access token.- Parameters:
scopes
- Scopes.- Returns:
this
object.
-
getAccessToken
public String getAccessToken()
Get the newly issued access token.- Returns:
- Access token.
-
setAccessToken
public TokenCreateResponse setAccessToken(String accessToken)
Set the newly issued access token.- Parameters:
accessToken
- Access token.- Returns:
this
object.
-
getTokenType
public String getTokenType()
Get the token type of the access token. For example,"Bearer"
.- Returns:
- Token type.
-
setTokenType
public TokenCreateResponse setTokenType(String tokenType)
Set the token type of the access token. For example,"Bearer"
.- Parameters:
tokenType
- Token type.- Returns:
this
object.
-
getExpiresIn
public long getExpiresIn()
Get the duration of the newly issued access token in seconds.- Returns:
- The duration of the access token.
-
setExpiresIn
public TokenCreateResponse setExpiresIn(long expiresIn)
Set the duration of the newly issued access token in seconds.- Parameters:
expiresIn
- The duration of the access token.- Returns:
this
object.
-
getExpiresAt
public long getExpiresAt()
Get the date at which the newly issued access token will expire. The value is expressed in milliseconds since Unix epoch (1970-01-01).- Returns:
- The date at which the newly issued access token will expire.
-
setExpiresAt
public TokenCreateResponse setExpiresAt(long expiresAt)
Set the date at which the newly issued access token will expire.- Parameters:
expiresAt
- The date at which the newly issued access token will expire. The value is required to be expressed in milliseconds since Unix epoch (1970-01-01).- Returns:
this
object.
-
getRefreshToken
public String getRefreshToken()
Get the newly issued refresh token.- Returns:
- Refresh token. This is
null
when the grant type is eitherIMPLICIT
orCLIENT_CREDENTIALS
.
-
setRefreshToken
public TokenCreateResponse setRefreshToken(String refreshToken)
Set the newly issued refresh token.- Parameters:
refreshToken
- Refresh token.- Returns:
this
object.
-
getProperties
public Property[] getProperties()
Get the properties associated with the access token.- Returns:
- Properties.
- Since:
- 1.34
-
setProperties
public TokenCreateResponse setProperties(Property[] properties)
Set the properties associated with the access token.- Parameters:
properties
- Properties.- Returns:
this
object.- Since:
- 1.34
-
summarize
public String summarize()
Get the summary of this instance.
-
getJwtAccessToken
public String getJwtAccessToken()
Get the newly issued access token in JWT format.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.- Returns:
- The newly issued access token in JWT format. If the service is not configured to issue JWT-based access tokens, this method always returns null.
- Since:
- 3.11
- See Also:
getAccessToken()
-
setJwtAccessToken
public TokenCreateResponse setJwtAccessToken(String jwtAccessToken)
Set the newly issued access token in JWT format.- Parameters:
jwtAccessToken
- The newly issued access token in JWT format.- Returns:
this
object.- Since:
- 3.11
-
getAuthorizationDetails
public AuthzDetails getAuthorizationDetails()
Get the authorization details associated with the access token.- Returns:
- Authorization details.
- Since:
- 2.99
-
setAuthorizationDetails
public TokenCreateResponse setAuthorizationDetails(AuthzDetails authorizationDetails)
Set the authorization details associated with the access token.- Parameters:
authorizationDetails
- Authorization details.- Returns:
this
object.- Since:
- 2.99
-
isForExternalAttachment
public boolean isForExternalAttachment()
Get the flag which indicates whether the access token is for an external attachment.- Returns:
true
if the access token is for an external attachment.- Since:
- 3.16
- See Also:
- OpenID Connect for Identity Assurance 1.0, External Attachments
-
setForExternalAttachment
public TokenCreateResponse setForExternalAttachment(boolean forExternalAttachment)
Set the flag which indicates whether the access token is for an external attachment.- Parameters:
forExternalAttachment
-true
to indicate that the access token is for an external attachment.- Returns:
this
object.- Since:
- 3.16, Authlete API 3.0
- See Also:
- OpenID Connect for Identity Assurance 1.0, External Attachments
-
getTokenId
public String getTokenId()
Get the unique token identifier.- Returns:
- The token identifier as a string.
- Since:
- 3.23, Authlete API 3.0
-
setTokenId
public TokenCreateResponse setTokenId(String tokenId)
Set the unique token identifier.- Parameters:
tokenId
- The token identifier as a string.- Returns:
this
object.- Since:
- 3.23, Authlete API 3.0
-
getRefreshTokenScopes
public String[] getRefreshTokenScopes()
Get the scopes associated with the refresh token.- Returns:
- The scopes associated with the refresh token. May be
null
. - Since:
- 3.89, Authlete API 3.0
-
setRefreshTokenScopes
public TokenCreateResponse setRefreshTokenScopes(String[] refreshTokenScopes)
Set the scopes associated with the refresh token.- Parameters:
refreshTokenScopes
- The scopes associated with the refresh token.- Returns:
this
object.- Since:
- 3.89, Authlete API 3.0
-
getClientIdentifier
public String getClientIdentifier()
Get the client Identifier associated with the newly issued access token.- Returns:
- Client Identifier.
- Since:
- 4.7, Authlete API 3.0
-
setClientIdentifier
public TokenCreateResponse setClientIdentifier(String clientIdentifier)
Set the client Identifier associated with the newly issued access token.- Parameters:
clientIdentifier
- Client Identifier.- Returns:
this
object.- Since:
- 4.7, Authlete API 3.0
-
-