Class 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 of action parameter from the response. The list below shows possible values of action 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 the grantType 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 the clientId 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 in accessToken parameter and refreshToken parameter.

    Since:
    1.13
    Author:
    Takahiko Kawasaki
    See Also:
    Serialized Form
    • Constructor Detail

      • TokenCreateResponse

        public TokenCreateResponse()
    • Method Detail

      • getAction

        public TokenCreateResponse.Action getAction()
        Get the code indicating how the response should be interpreted. See the description 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 the description of this class for details.
        Parameters:
        action - The code indicating how the response should be interpreted.
        Returns:
        this object.
      • getGrantType

        public GrantType getGrantType()
        Get the grant type for the newly issued access token.
        Returns:
        Grant type.
      • setGrantType

        public TokenCreateResponse setGrantType​(GrantType grantType)
        Set the grant 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 is null when the grant type obtained by getGrantType() is CLIENT_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 either IMPLICIT or CLIENT_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
      • 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