Generate Oracle OAuth Tokens

To connect Oracleto a Knowledge Hub knowledge base, you must either provide your Oraclecredentials to NiCE Professional Services or enter them in Knowledge Hub yourself. This page describes how to configure Basic and JWT ( OAuth 2) authentication methods to access Oracle Knowledge Management Cloud or Oracle Service Cloud REST APIs. Basic authentication uses a username and password for direct access, while JWT ( OAuth 2) is a token-based method that enables Oracle to request and use access tokens for secure communication with Knowledge Hub.

You should treat the OAuth tokens like passwords. Be sure to store them in a secure location. If you lose them, you'll have to regenerate them.

This method is a developer effort. It requires knowledge of Python.

Complete each of these tasks in the order given.

Install Python

Complete this task if you don't already have Python installed on your computer.

  1. Install Python Box with arrow indicating navigation to external site..

  2. Run the installer. Select the box for Add python.exe to PATH, then click Install Now.

Configuring Basic Authentication in Oracle

Create a user in Oracle with API access.

  1. Log in to your Oracle Knowledge Management Cloud application.

  2. Go to User Management.

  3. Create a new user or select an existing user for API access.

  4. Assign a strong password to the user.

  5. Assign the appropriate roles.

    • For Knowledge Management, assign at least Knowledge Author or Knowledge Manager.

    • The Username and Password are used in the Basic Authentication headers.

Configuring JWT (OAuth 2) Authentication in Oracle

Register a confidential application in Oracle Cloud Console.

  1. Log in to your Oracle Cloud Console.

  2. Navigate to Identity & Security > Identity > Federation > (Your Domain) > Applications.

  3. Create a new Confidential Application:

    • Enter a name for the application.

    • Enable Client Credentials or JWT Assertion grant types.

    • Upload your public key for JWT validation.

    • Save your changes.

  4. Note the following values:

    • Client ID

    • Client Secret

Generate Access Token

You can generate a JWT token using either a Python script or a curl command.

Generating Access Token using Python Script

Replace <client_id> with your application’s client ID and <oracle-cloud-host> with your Oracle Cloud host.

import jwt

import time

private_key = open('private_key.pem').read()

now = int(time.time())

payload = {

"iss": "<client_id>",

"sub": "<client_id>",

"aud": "<oracle-cloud-host>",

"exp": now + 300,

"iat": now

}

token = jwt.encode(payload, private_key, algorithm='RS256')

print(token)

Generating an Access Token Using Curl

curl -X POST \

https://your-idcs-domain.identity.oraclecloud.com/oauth2/v1/token \

-H 'Authorization: Basic <base64(client_id:client_secret)>' \

-H 'Content-Type: application/x-www-form-urlencoded' \

-d 'grant_type=client_credentials'