Data and metadata service APIs use a JSON Web Token (JWT) for authentication and
authorization. When you call an API by using the HTTP Authorization request header, you must supply
an unexpired token that has the proper scope and that is signed by an approved JSON Web Key (JWK).
Before you begin
- Find the account, organization, and client IDs.
-
Log in to Intelligence suite.
-
Select the organization and account that you are using.
- Open the Information page.
A list of account,
organization, and client IDs that you need to access the API services is displayed.
Note: Client
ID is prefixed with the service name.
In the following client ID example,
saascore is a service, so the ID is prefixed with
saascore.
saascore-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
- Make a note of all the IDs.
- Get an API key. You need to generate the API key only once to generate the identity and access
management (IAM) token, and this key does not expire after it is created.
- Log in to IBM Cloud®.
- From the menu bar, select .
- From the side navigation menu, in the Manage identities section, click
API keys.
- To create the IBM Cloud API key, click
Create and add a name and description.
- Click Create.
- Copy the API key or click Download to save it.
Procedure
- Generate a token.
- To create an IAM token, send the POST API request as shown in the following cURL
example.
Make sure that you replace
<<YOUR_IAM_APIKEY>> with your key in the request.
curl --location --request POST 'https://iam.cloud.ibm.com/identity/token' \
--data-urlencode 'grant_type=urn:ibm:params:oauth:grant-type:apikey' \
--data-urlencode 'apikey=<<YOUR_IAM_APIKEY>>'
This request returns an IAM token. Make a note of the IAM
token.
- Generate a JWT token.
In the following cURL example, the IAM token is used
to generate a JWT token to access saascore service.
Make sure that you
replace
<<YOUR_ORGID>>,<<CLIENT_ID>>,
and
<<YOUR_IAM_TOKEN>> with your organization ID,
client ID, and IAM token in the
request.
curl --location --request GET 'https://api.ibm.com/saascore/run/authentication-retrieve?orgId=<<YOUR_ORGID>>\
--header 'X-IBM-Client-Id: saascore-<<CLIENT_ID>>' \
--header 'Authorization: Bearer <<YOUR_IAM_TOKEN>>'
The result of this call is a JWT token. Save the JWT token for
subsequent API calls. JWT tokens typically expire after about 60 minutes after which you need to
fetch a new token.
- Authenticate your account.
In the following cURL example, the JWT token is used to authenticate your account.
curl --location --request <GET/POST> '<INSERT_API_ENDPOINT_HERE>' \
--header 'x-ibm-client-Id: <service-prefix>-<INSERT_YOUR_CLIENT_ID_HERE>' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <INSERT_YOUR_JWT_HERE> \