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

Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.