This article explains how to setup a custom Java Web App for calling a Boomi published API that uses OAuth 2.0 for authentication.
Please note that this application was developed only for demonstration purposes. It uses the Google Oauth Client Library for Java (https://developers.google.com/api-client-library/java/google-oauth-java-client/oauth2) to simplify the implementation. No support is provided for this application.
This solution assumes you are familiar with and using API Management. and have setup an Authentication Broker with External Authentication. See Getting Started with External Authentication for API Management.
Google Identity Provider Setup
This setup was done with an External Authentication Broker setup with Google's Identity Provider. Other identity providers such as Okta, Auth0, etc, may be used. The following steps should be performed as part of the Broker setup but it is shown here again to illustrate how a Client ID and Client Secret can be generated:
- Login to https://console.developers.google.com/
- Create a new project by clicking on the project link:
- Click on “Credentials” then “Create credentials”:
- Click on “OAuth client ID”:
- Enter a name and redirect URLs. Click “Create”:
NOTE: the redirect URL http://localhost:8080/BoomiOauthClient/index.jsp must be added for the Custom client to work.
- Note the generated “Client ID” and “Client secret”:
Custom Java Web Client Configuration
Eclipse & Tomcat Setup
The Boomi Oauth Client is a Java Web Application which requires an IDE such as Eclipse to modify and run.
- Download and install Eclipse for Java EE development.
- Install Tomcat 8 (9 does not work with Eclipse).
- Configure Eclipse with a Tomcat server runtime:
Custom Boomi Oauth Client Installation
- Import the project zip file "BoomiOauthClient.zip" into Eclipse:
- Open “AuthHelper.java” and modify the "AUTH PARAMETERS" section:
NOTE: the CALLBACK_URI does not need to be changed if you are running Tomcat on your local machine.
- Add the project to the Tomcat runtime (right click on the Tomcat runtime -> click “Add and Remove”).
- Run the server until it says “Started, Synchronized”:
Running the Application
- Open a browser and go to http://localhost:8080/BoomiOauthClient/index.jsp (replace localhost with your hostname if running on a different server).
- Enter the API’s URL in the “Resource URL” field and click “Set Resource URL”:
NOTE: This client can only do a GET operation
- This will set the Resource URL:
- Now click on “Call API”:
- You will be redirected to the Google login page (if the Auth Broker is setup to use Google):
- If successful it will return the results:
- Click “Reset” to reset the page.