Java Web Application for Calling a Boomi Published API with OAuth 2.0 Authentication

Document created by andrew_zeon065198 Employee on Feb 4, 2018Last modified by Adam Arrowsmith on Feb 12, 2018
Version 8Show Document
  • View in full screen mode

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.

 

 

Prerequisites

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:

 

  1. Login to https://console.developers.google.com/ 
  2. Create a new project by clicking on the project link:
  3. Click on “Credentials” then “Create credentials”:
  4. Click on “OAuth client ID”:
  5. 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.
  6. 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. 

 

  1. Download and install Eclipse for Java EE development.
  2. Install Tomcat 8 (9 does not work with Eclipse).
  3. Configure Eclipse with a Tomcat server runtime:

 

Custom Boomi Oauth Client Installation

  1.  Import the project zip file "BoomiOauthClient.zip" into Eclipse:

  2. 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. 
  3. Add the project to the Tomcat runtime (right click on the Tomcat runtime -> click “Add and Remove”).
  4. Run the server until it says “Started, Synchronized”:

 

Running the Application

  1. Open a browser and go to http://localhost:8080/BoomiOauthClient/index.jsp (replace localhost with your hostname if running on a different server).
  2. Enter the API’s URL in the “Resource URL” field and click “Set Resource URL”:

    NOTE: This client can only do a GET operation
  3. This will set the Resource URL:
  4. Now click on “Call API”:
  5. You will be redirected to the Google login page (if the Auth Broker is setup to use Google):
  6. If successful it will return the results:
  7. Click “Reset” to reset the page.

1 person found this helpful

Attachments

Outcomes