Chapter 10. Using Image Builder API
The Image Builder API contains examples for using various types of request. Administrators and developers can use the Image Builder API to write custom scripts to integrate Image Builder services with third-party applications.
10.1. Generating an access token for the Image Builder API queries
The Image Builder API queries require an active access token. The access token expires after 900 seconds after its creation. To generate the access token, follow the steps below.
Prerequisites
- You have a RHEL subscription.
- You have a service account in the Red Hat Hybrid Cloud Console. For details, see Creating a service account.
Procedure
To generate the access token, include the following code in your script in the Authorization header with the value
Bearer $ACCESS_TOKEN
:CLIENT_ID="YOUR_CLIENT_ID" CLIENT_SECRET="YOUR_CLIENT_SECRET" ACCESS_TOKEN=$( \ curl -d "client_id=$CLIENT_ID" \ -d "client_secret=$CLIENT_SECRET" \ -d "grant_type=client_credentials" \ "https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token" \ -d "scope=api.console" \ | jq -r .access_token \ )
Replace YOUR_CLIENT_ID with the client ID, and YOUR_CLIENT_SECRET with the client secret from your service account.
Additional resources
- For more information about Image Builder API, see Image Builder API catalogue.