Obtaining JSON Web Tokens in Liberty

You can obtain JSON Web Token (JWT) tokens from the JWT token generation endpoint in the jwt-1.0 feature.

About this task

For information about JWT APIs, see the Json Web Token or the API documentation that is included in the product in the ${wlp.install.dir}/dev directory.

Procedure

  1. If you did not include credentials in the request, authenticate with your credentials to access the JWT token generation endpoint at the following URL:
    https://<host>:<port>/jwt/ibm/api/<configId>/token

    After authentication succeeds, the MP-JWT format token is returned in JSON form. The token contains the user and groups for the user as recorded in the user registry of the server.

  2. Use the <configId> ID to refer to a corresponding JWTBuilder entry in the server.xml file. Specify token attributes, such as issuer and expiration time, in the JWTBuilder entry.
  3. If you do not define JWTBuilder elements in the server.xml file, use the defaultJWT element as the <configId> ID.
  4. Find the available JWT builder configuration attributes at jwtBuilder - JWT Builder (jwtBuilder).