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.
Prerequisites
Section titled “Prerequisites”- Ensure you have Python installed on your local machine.
- Install venv if you haven’t already:
Terminal window python -m pip install --user virtualenv - When in the keycloak repository root folder, create a virtual environment and activate it:
Terminal window python -m venv venvsource venv/bin/activate # On Windows use `venv\Scripts\activate` - Add the resource definitions to the
scripts/api_clients.jsonfile. Follow the existing structure to define the new resources. - Run the python script and provide the necessary inputs when prompted:
Terminal window python scripts/run.py - 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).