Example: Using Keycloak, MP and OpenLiberty locall
  • Introduction
  • Setup the sample application
    • Step 1 - Start and configure Keycloak
    • Step 2 - Understand and configure the Authors microserice on OpenLiberty
    • Step 3 - Understand the JUnit test implementation
  • Start the Microservice and execute the test
    • Step 1 - Start the OpenLiberty server and execute the JUnit test
    • (Optional) Extract the JWT from a bearer token
  • Additional Resources
    • MicroProfile JWT Authentication with Keycloak and React (Philip Riecks)
    • MicroProfile JWT with Keycloak (Hayri Cicek)
    • MicroProfile Rest Client for RESTful communication (Philip Riecks)
    • JAX-RS - @POST with HTML Form Example (LogicBig.com)
    • Java Code Examples for javax.ws.rs.client.WebTarget (programcreek)
    • Code sample form and entity (Codota)
    • API login and JWT token generation using Keycloak (RedHat Developers)
    • JWT Decoder (JWT.io)
    • Write and execute a JUnit (Thomas Suedbroecker)
  • Known problems
    • Keycloak, not returning access token, if update password action selected
Powered by GitBook
On this page

Was this helpful?

  1. Start the Microservice and execute the test

(Optional) Extract the JWT from a bearer token

PreviousStep 1 - Start the OpenLiberty server and execute the JUnit test

Last updated 4 years ago

Was this helpful?

To examine Java Web Token format you get from keycloak, you can use to extract the content from a bearer token.

{
  "exp": 1585571903,
  "iat": 1585571603,
  "jti": "f5cec896-d1b7-42d5-aaa1-c346daa41394",
  "iss": "http://localhost:8282/auth/realms/cloudnativestarter",
  "aud": "account",
  "sub": "69ac13eb-efe4-407d-9d2f-a07c50cfbb6f",
  "typ": "Bearer",
  "azp": "authors-client-cloud-native-starter",
  "session_state": "bedb8cab-7253-40a5-a64e-87a2bd0938d1",
  "acr": "1",
  "realm_access": {
    "roles": [
      "authors-role-cloud-native-starter"
    ]
  },
  "resource_access": {
    "account": {
      "roles": [
        "manage-account",
        "manage-account-links",
        "view-profile"
      ]
    }
  },
  "scope": "profile email",
  "email_verified": false,
  "groups": [
    "authors-role-cloud-native-starter"
  ],
  "preferred_username": "author-cloud-native-starter"
}
JWT.io