Saturday, November 28, 2026

OIC - Automatic OAuth 2.0 Token Generation Using REST Connection

1. Introduction

In Oracle Integration Cloud (OIC), when integrating with external applications that use OAuth 2.0 authentication, we generally retrieve the Client ID and Client Secret from OCI Vault, invoke the token API separately, extract the access token, and pass it in the Authorization header while invoking the actual API.

However, OIC provides a simpler approach using the OAuth Custom Two Legged Flow security policy available in the REST Adapter. With this configuration, OIC can automatically generate and manage the access token without requiring separate token-generation logic in the integration.

2. Use Case

Consider an integration that needs to invoke an external application API secured using OAuth 2.0. The application expects the access token in the HTTP Authorization header.

Traditional Approach:

  • Retrieve Client ID and Client Secret from OCI Vault.
  • Invoke the OAuth token API.
  • Extract the access token from the response.
  • Store the token in an integration variable.
  • Pass the token in the Authorization header while invoking the actual API.

Proposed Approach:

Configure OAuth authentication directly in the OIC REST connection. OIC handles token generation and passes the token automatically in the Authorization header.

3. REST Connection Configuration

  1. Navigate to OIC → Connections → Create Connection → REST Adapter.
  2. Configure the following properties:
    1. Connection Type: REST API
    2. Role: Invoke
    3. Connection URL: External application base URL
    4. Security Policy: OAuth Custom Two Legged Flow

Step 1: Configure Access Token Request

Configure the token endpoint using cURL syntax.

Example for header-based client authentication:

-X POST "https://hostname.com/api/oauth2/v1/access" \

-H "Authorization: Basic ${security_field_1}"

Here, client credentials are passed through the HTTP Authorization header. No request body is required when the external token API supports header-based authentication without body parameters.

Note: Security_field_1 = base64 encoded (user:password)

Step 2: Configure Optional Security

Configure the security fields:

Security Field 1: Base64-encoded client credentials.

Security Field 2: Additional secret, if required by the application.

These values are securely maintained in the OIC connection rather than hardcoded in the integration.

Step 3: Configure Token Response Mapping

Assume the token API returns the following response:

{

  "access_token": "xxxxxxxx",

  "token_type": "Bearer",

  "expires_in": 3600

}

Configure the response extraction fields:

$access_token: access.[tT]oken

$refresh_token: refresh.[tT]oken

$expiry: expires_in

$token_type: token.?[tT]ype

Step 4: Configure Access Token Usage

Under Access Token Usage, configure:

-H Authorization: ${token_type} ${access_token}

OIC automatically uses the generated token in the Authorization header when invoking the target API.

For example:

Authorization: Bearer xxxxxxxxx.

4. Integration Flow

Start Integration → Invoke REST Connection → OIC Automatically Generates/Manages Access Token → Invoke External Application API

There is no need to create a separate token-generation integration or manually extract and map the access token.

5. Benefits

  • Eliminates separate token-generation logic.
  • Avoids manual credential retrieval from OCI Vault within the integration.
  • Eliminates manual access-token extraction and variable assignment.
  • Simplifies integration orchestration.
  • Centralizes authentication configuration at the connection level.
  • Improves maintainability and reusability.

6. Important Considerations

  • The external application must support a compatible OAuth two-legged authentication flow.
  • Configure the token request according to the provider's API specification, especially header-based versus body-based authentication.
  • Configure the correct token response extraction patterns.
  • Maintain sensitive credentials in secured connection fields.
  • Test the connection to validate successful token generation and API invocation.

7. Conclusion

OAuth Custom Two Legged Flow is a useful OIC feature for simplifying integrations with OAuth-secured external applications. Instead of implementing separate logic to retrieve credentials, generate tokens, and pass them to the target API, we can configure authentication directly in the REST connection.


No comments:

Post a Comment

Featured Post

OIC - Automatic OAuth 2.0 Token Generation Using REST Connection

1. Introduction In Oracle Integration Cloud (OIC), when integrating with external applications that use OAuth 2.0 authentication, we general...