Step-by-step
-
Prerequisites: APIC User Resgistry and User Setup
APIC Cloud Manager (CM) and API Manager (APIM) will allow for LUR (local user reg) and LDAP user registry.
NOTE: ibm-bluepages is a LDAP user registry.
1. This is the following call for the identity-providers for the CM:
2. This is the following call for the identity-providers for the APIM:
Create restapiuser member on the local user register from CM to administrate APIC with rest api calls.
Create an App with a client_id and secret and register the app
Register an application with the restapi user.
First find the identity provider where the restapi user resides on APIC using the APIC toolkit:
NOTE: the scope may be admin or provider
$ apic identity-providers:list –scope admin –server apic.ibm.com
Note: The ibm-bluepages is the ldap user registry.
- Then issue $ apic login to log into the APIC management server.
-
Create a json file titled app1.json, and include your own unique details as shown as below.
{
"name": "willsapp",
"client_id": "app1id",
"client_secret": "app1secret",
"client_type": "toolkit"
}
- Then register the app with the following command.
$apic registrations:create –server apic.ibm.com app1.json
Once the app is registered, you can invoke the rest apis.
Again, you could download the swagger from the APIC REST API doc overview section of the Cloud Management section: https://apic-api.apiconnect.ibmcloud.com/v10/
Getting tokens
Upload the swagger from the overview section of the Cloud Management section from https://apic-api.apiconnect.ibmcloud.com/v10 to your postman environment and locate the rest api “Generate a token”
Ensure that you update the base url to the platform URL gathered in the ingredients section of this note.
In the headers section, you may omit all the params and following headers. Ensure that the Accept header is added for application/json.
In the body, enter in the relevant details required to call the token endpoint.
- Grant_type: hardcoded for ‘password’
- Username: the apic admin account created for this exercise.
- Password: the password for the apic admin account
- Realm: Use the identity provider you got from the apic identity-providers call in the “Create an app with client_id and secret” section of this doc. Ensure you have admin/ appended because it denotes the Cloud Manager (the provider/ is the API Manager).
- Client_Id: the client_id you input in the app1.json file from the section “Create an app with client_id and secret” section of this doc.
- Client_secret: the client_secret you input in the app1.json file from the section “Create an app with client_id and secret” section of this doc
HINT: you could go into the setting of the IBM API Connect Platform Collection to update the url and set variables on this collection.
- In the Variable tab update the baseURL to your platform api url.
- In the Variable tab add the org variable reflecting your provider organization.
- In the Authorization tab add the {{token}} variable key.
- Then click Update to update the values.
To set the Token variable, go back to the “Generate a token”, navigate into the Tests section of the test case, and enter the set variable logic:
var jsonData = JSON.parse(responseBody);
pm.globals.set("token", jsonData.access_token);
Now, you just have to invoke the “Generate a token” API from the IBM API Connect Platform Collection, and the generated token response will be set as the token value to invoke the REST apis.