Authenticate API requests

Request an access token

When using Red Hat Marketplace API, access tokens allow access to Red Hat Marketplace resources. To get an access token, refer to the following procedure.

Prerequisites

Procedure

  • Call the Authentication API. Pass the API key in the body of the request.

Result

The access token shows on the response.

Authentication API reference

Refer to the following details when making a request for an access token.

MethodPath
POST/api-security/om-auth/cloud/token

Request headers

  • Content-Type: application/x-www-form-urlencoded
  • Accept: application/json

Request body parameters

  • grant_type=urn:ibm:params:oauth:grant-type:apikey
  • apikey=${API_KEY}

Example request

Use the following curl and jq commands to generate an access token using an API key.

curl -l \
-X POST "https://marketplace.redhat.com/api-security/om-auth/cloud/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json" \
-d "grant_type=urn:ibm:params:oauth:grant-type:apikey&apikey=${API_KEY}" \
jq -r '.access_token'

Use an access token to authenticate a request

To authenticate, use bearer auth and pass your access token in the header of your request.

Example authentication header

curl https://marketplace.redhat.com/account/api/v1/accounts \
-H "Authorization: Bearer ${access_token}"