Generating the JWT Token for AWS

The AWS offering uses a JSON Web Token(JWT) to authenticate you in the watsonx Orchestrate API. To get this token, you have to make a request to the API by passing your API key.

Before you begin

You must have an API Key to generate your JWT Token. To learn how to generate an API key, see Generating an API Key for AWS.

Generating the Token

After generating the API key, to get the JSON Web Token(JWT), make a request to the authentication endpoint and pass the generated API key.

The following URL is the authentication endpoint:

https://iam.platform.saas.ibm.com/siusermgr/api/1.0/apikeys/token

To call the authentication endpoint, you can use the following example code blocks:

curl

curl -X POST "https://iam.platform.saas.ibm.com/siusermgr/api/1.0/apikeys/token" \
     -H "Content-Type: application/json" \
     -H "Accept: application/json" \
     -d '{
           "apikey": "MY_API_KEY"
         }'

Python

import http.client

conn = http.client.HTTPSConnection("iam.platform.saas.ibm.com")

payload = """
{
    "apikey": "MY_API_KEY"
}
"""

headers = {
    'content-type': "application/json",
    'accept': "application/json"
}

conn.request("POST", "/siusermgr/api/1.0/apikeys/token", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
const url = "https://iam.platform.saas.ibm.com/siusermgr/api/1.0/apikeys/token";

const payload = {
  apikey: "MY_API_KEY"
};

fetch(url, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Accept": "application/json"
  },
  body: JSON.stringify(payload)
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error("Error:", error));

Note: Replace MY_API_KEY with your API key.