This guide supplies instructions for integrating IBM API Connect with the IBM blueID IDaaS OpenID Connect provider.
One of the limitations in using the IBM IDaaS is that there is no way to automatically create clients in the blueID system. That means, any applications registered in the API Connect developer portal must be manually registered in the blueID system as well.
Other 3rd-party OAuth/OIDC providers such as IBM's ISAM or Ping Federate have APIs which would allow synchronization of the client credentials between API Connect and the provider registry.
Sections of this guide:
-
Register an Application in the API Connect Developer Portal
-
Register a blueID Application and Client
-
Configure an API to use blueID ODIC
-
Publish and subscribe to the API Product
-
Test the API
-
Log in to the API Connect Developer Portal for your desired Catalog.
-
Select the
Appsoption from the menu bar. -
Click the button to
Create new App. -
Give the application a title and click the
Submitbutton. -
Select to show the Client ID and save the value to a notepad.
-
Select to show the Client Secret and save the value to a notepad.
-
Launch the IBM SSO Self-Service Portal:
-
Click on the Register a blueID application link.
-
Accept the Terms and Conditions.
-
Fill out the Application Details form, this page includes details for the API you’re developing.
-
Select the Pre-Production identity provider.
-
Register a blueID Client Application.
-
Provide a unique Client Name.
-
Remove the auto-generated Client ID and Client Secret.
-
Enter the Client ID and Client Secret from the Application generated by the APIC Developer Portal.
-
Enter the following Redirect URL's:
-
Select the desired grant types.
-
Take note of the endpoints.
-
Click the Continue button.
-
Confirm the details, scroll to the bottom and click the Save and Continue button.
-
You will receive an email stating that the application request was received followed a few minutes later by a second email stating that the request was successful.
-
Log in to the API Manager server and navigate to the Draft APIs section.
-
Click the
Add +button and chose toImport API from a file or URL. -
Click on the
Or import from URL...and provide the url: -
Navigate to the Security Definitions section.
-
Ensure that you have security definitions that require the Client ID and Client Secret, both are required for blueID OIDC to work.
-
Create a new Security Definition for OAuth.
-
Scroll down to configure the OAuth security definition.
-
Rename the Security Definition.
-
Select the desired grant type flow.
Note: The flow selected here is for informational purposes within the developer portal. Whichever flow you decide to use must be enabled for the blueID client. To remain consistent with this guide, I suggest you use the
Access Codeflow. -
Enter the blueID endpoints for the
Authorization URL,Token URLandIntrospection URL. -
Add a new scope to the Security Definition called
openid. -
Scroll down to the Security section of the API definition and ensure all three Security Definitions are selected, along with the two OAuth scopes.
-
Save the API definition.
-
Click on the menu button for the API located in the top-right corner and chose to
Generate a default product. -
Scroll down and chose the option to
Publish this product to a catalog. -
Select the desired catalog from the list and click on the
Create productbutton. -
Open a new browser tab and log in to the Catalog’s Developer Portal.
-
Select the API Products tab and select your new
logistics product. -
Click the Subscribe button to link your registered application to the API Product.
Note: The IBM blueID IDaaS prohibits cross-orgin requests from client-side browser applications. Unfortunately, this means we cannot use the API Connect Developer Portal to obtain a token from the blueID system. To test the API, you need to use a server-side application.
In the following section, I use an API test client called Postman which is available for free here: https://www.getpostman.com/. I have built a test Collection for Postman that you can import and configure to your environment.
-
Launch your test client and click the
Importbutton. -
Chose the
Import From Linkoption and provide the following URL: -
Click on the environment view icon and chose to edit the
Globalssection. -
You will need to set up the following variables. You can chose the
Bulk Editoption and provide the text snippet below with your environment-specific values.apic-host:<your api host> apic-org:<your org name> apic-catalog:<your catalog name> blueid-auth-url:https://prepiam.toronto.ca.ibm.com/idaas/oidc/endpoint/default/authorize blueid-token-url:https://prepiam.toronto.ca.ibm.com/idaas/oidc/endpoint/default/token client-id:<your client id> client-secret:<your client secret> -
If you send a test request now, you will receive an error code because no authentication token has been set.
-
Open the
Logistics + OIDCtest request and click on theAuthorizationtab, followed by theOAuth 2.0option in the drop down menu. -
Click the
Get New Access Tokenbutton. -
Fill in the token request form:
-
Give the token a name, this will be used later as a selection option.
-
Use the Postman environment variable names inside of double curly braces to avoid having to re-copy and re-paste all of the values.
-
Set the scope to
openid. -
Click on the
Request Tokenbutton.
-
-
In this demo, I am using the Authorization Code (3-Legged OAuth Grant Type) flow. A pop-up window will ask to enter your IBMid and Password.
Note: When setting up the blueID client, we selected the Pre-Production identity provider. If you do not have an email account in the Pre-Production system, use the Create an IBMid link to set up an account before trying to log in.
-
Once you sign-in, Postman will automatically save the token for use in your API calls.
-
Select the
blueIDtoken from the Existing Tokens section, select theHeaderoption from theAdd token tomenu. -
Then click on the Use Token button to add it to the request headers.
-
You’re now ready to call the API hosted on the IBM API Connect platform. Click the Send Request button and view the response.
Note: The API Gateway is configured with the IBM blueID Introspection URL. When a request is made to the secure API, the gateway will extract the token from the request headers and validate it with the blueID system.