Skip to content

Configure resources

When a new resource is added to one of our API services, we need to configure Keycloak to recognize and manage access to that resource.

A python script is provided in the keycloak repository to automate the process of adding new resources to Keycloak.

  1. Ensure you have Python installed on your local machine.
  2. Install venv if you haven’t already:
    Terminal window
    python -m pip install --user virtualenv
  3. When in the keycloak repository root folder, create a virtual environment and activate it:
    Terminal window
    python -m venv venv
    source venv/bin/activate # On Windows use `venv\Scripts\activate`
  4. Add the resource definitions to the scripts/api_clients.json file. Follow the existing structure to define the new resources.
  5. Run the python script and provide the necessary inputs when prompted:
    Terminal window
    python scripts/run.py
  6. Also select how you want to sync the changes to Keycloak. Depending on if one or more clients are affected you can choose to update a single client or all clients. For now you’ll only want to update a single realm (Kalmar Energi).