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/createAPI.Authlete's
/auth/token/createAPI returns JSON which can be mapped to this class. The first step that a caller should take is to retrieve the value ofactionparameter from the response. The list below shows possible values ofactionparameter and their meanings.INTERNAL_SERVER_ERROR-
When the value of
actionparameter is"INTERNAL_SERVER_ERROR", it means that an error occurred on Authlete side. BAD_REQUEST-
When the value of
actionparameter is"BAD_REQUEST", it means that the request from the caller was wrong. For example, this happens when thegrantTyperequest parameter is not specified. FORBIDDEN-
When the value of
actionparameter is"FORBIDDEN", it means that the request from the caller is not allowed. For example, this happens when the client application identified by theclientIdrequest parameter does not belong to the service identified by the API key used for the API call. OK-
When the value of
actionparameter 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
actionparameter in the response from Authlete's/auth/token/createAPI is"OK", you can find a new access token and optionally a new refresh token inaccessTokenparameter andrefreshTokenparameter.- Since:
- 1.13
- Author:
- Takahiko Kawasaki
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTokenCreateResponse.ActionThe 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 StringgetAccessToken()Get the newly issued access token.TokenCreateResponse.ActiongetAction()Get the code indicating how the response should be interpreted.AuthzDetailsgetAuthorizationDetails()Get the authorization details associated with the access token.longgetClientId()Get the client ID associated with the newly issued access token.StringgetClientIdentifier()Get the client Identifier associated with the newly issued access token.longgetExpiresAt()Get the date at which the newly issued access token will expire.longgetExpiresIn()Get the duration of the newly issued access token in seconds.GrantTypegetGrantType()Get thegrant typefor the newly issued access token.StringgetJwtAccessToken()Get the newly issued access token in JWT format.Property[]getProperties()Get the properties associated with the access token.StringgetRefreshToken()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.StringgetSessionId()Get the session ID, which is the ID of the user's authentication session, associated with a newly created access token.StringgetSubject()Get the subject (= unique identifier) of the user associated with the newly issued access token.StringgetTokenId()Get the unique token identifier.StringgetTokenType()Get the token type of the access token.booleanisForExternalAttachment()Get the flag which indicates whether the access token is for an external attachment.TokenCreateResponsesetAccessToken(String accessToken)Set the newly issued access token.TokenCreateResponsesetAction(TokenCreateResponse.Action action)Set the code indicating how the response should be interpreted.TokenCreateResponsesetAuthorizationDetails(AuthzDetails authorizationDetails)Set the authorization details associated with the access token.TokenCreateResponsesetClientId(long clientId)Set the client ID associated with the newly issued access token.TokenCreateResponsesetClientIdentifier(String clientIdentifier)Set the client Identifier associated with the newly issued access token.TokenCreateResponsesetExpiresAt(long expiresAt)Set the date at which the newly issued access token will expire.TokenCreateResponsesetExpiresIn(long expiresIn)Set the duration of the newly issued access token in seconds.TokenCreateResponsesetForExternalAttachment(boolean forExternalAttachment)Set the flag which indicates whether the access token is for an external attachment.TokenCreateResponsesetGrantType(GrantType grantType)Set thegrant typefor the newly issued access token.TokenCreateResponsesetJwtAccessToken(String jwtAccessToken)Set the newly issued access token in JWT format.TokenCreateResponsesetProperties(Property[] properties)Set the properties associated with the access token.TokenCreateResponsesetRefreshToken(String refreshToken)Set the newly issued refresh token.TokenCreateResponsesetRefreshTokenScopes(String[] refreshTokenScopes)Set the scopes associated with the refresh token.TokenCreateResponsesetScopes(String[] scopes)Set the scopes associated with the newly issued access token.TokenCreateResponsesetSessionId(String sessionId)Set the session ID, which is the ID of the user's authentication session, associated with a newly created access token.TokenCreateResponsesetSubject(String subject)Set the subject (= unique identifier) of the user associated with the newly issued access token.TokenCreateResponsesetTokenId(String tokenId)Set the unique token identifier.TokenCreateResponsesetTokenType(String tokenType)Set the token type of the access token.Stringsummarize()Get the summary of this instance.-
Methods inherited from class com.authlete.common.dto.ApiResponse
getResponseHeaders, getResultCode, getResultMessage, setResponseHeaders, setResultCode, setResultMessage
-
-
-
-
Method Detail
-
getAction
public TokenCreateResponse.Action getAction()
Get the code indicating how the response should be interpreted. See thedescriptionof 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 thedescriptionof this class for details.- Parameters:
action- The code indicating how the response should be interpreted.- Returns:
thisobject.
-
getGrantType
public GrantType getGrantType()
Get thegrant typefor the newly issued access token.- Returns:
- Grant type.
-
setGrantType
public TokenCreateResponse setGrantType(GrantType grantType)
Set thegrant typefor the newly issued access token.- Parameters:
grantType- Grant type.- Returns:
thisobject.
-
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:
thisobject.
-
getSubject
public String getSubject()
Get the subject (= unique identifier) of the user associated with the newly issued access token. This value isnullwhen thegrant typeobtained 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:
thisobject.
-
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:
thisobject.
-
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:
thisobject.
-
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:
thisobject.
-
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:
thisobject.
-
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:
thisobject.
-
getRefreshToken
public String getRefreshToken()
Get the newly issued refresh token.- Returns:
- Refresh token. This is
nullwhen the grant type is eitherIMPLICITorCLIENT_CREDENTIALS.
-
setRefreshToken
public TokenCreateResponse setRefreshToken(String refreshToken)
Set the newly issued refresh token.- Parameters:
refreshToken- Refresh token.- Returns:
thisobject.
-
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:
thisobject.- 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
Serviceclass.- 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:
thisobject.- 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:
thisobject.- Since:
- 2.99
-
isForExternalAttachment
public boolean isForExternalAttachment()
Get the flag which indicates whether the access token is for an external attachment.- Returns:
trueif 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-trueto indicate that the access token is for an external attachment.- Returns:
thisobject.- 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:
thisobject.- 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:
thisobject.- 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:
thisobject.- Since:
- 4.7, Authlete API 3.0
-
getSessionId
public String getSessionId()
Get the session ID, which is the ID of the user's authentication session, associated with a newly created access token.- Returns:
- The session ID.
- Since:
- 4.18, Authlete API 3.0
-
setSessionId
public TokenCreateResponse setSessionId(String sessionId)
Set the session ID, which is the ID of the user's authentication session, associated with a newly created access token.- Parameters:
sessionId- The session ID.- Returns:
thisobject.- Since:
- 4.18, Authlete API 3.0
-
-