Retrieving access tokens for API usage

To authenticate API requests in IBM® Optim Data Privacy, you must retrieve a valid JSON Web Token (JWT) access token. This token is required in the Authorization header for all API calls.

Methods to retrieve the access token

Method 1: Using the IBM Optim authentication API

Use the following command to retrieve the access token:


curl -kX POST https://VM_HOSTNAME:7725/optim/v1/auth/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d 'username={user}&password={password}' | jq '.requestObj.access_token'
Method 2: Using the OpenID connect token endpoint (if minimal ports are open)

If minimal ports are open, use this alternative method:


curl -kX POST https://VM_HOSTNAME:OPTIM_UI_PORT/realms/optim/protocol/openid-connect/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d 'grant_type=password&client_id=optim-public-client&scope=openid%20organization&username={user}&password={password}' | jq '.access_token'

Replace {user} and {password} with your actual credentials. The returned token is a JWT and must be included in the Authorization header as Bearer <accessToken> in all API requests.

Using the access token

Include the token in the Authorization header for all API requests:


Authorization: Bearer <accessToken>