Authentication

To use CDQ APIs, you must properly authenticate our services. For authentication, you can use the API key or OAuth2 Client Credentials.

Prerequisites

  1. If your organization is already a CDQ customer, ask your internal point of contact to create a CDQ dedicated account. Account detail will be sent by email.
  2. If your organization is not yet a CDQ customer, please contact us to get started.

Step 1: API Key Management

attention

This step is common for both methods of authentication. The required type of authentication will be distinguished in the further steps.

  1. Log into the CDQ Cloud Apps

auth1

  1. Navigate to the "API Key Management" App

auth2

attention

If no API Key Management App is visible, contact your local admin for API Key creation.

Step 2: Generate the authentication details

  1. Select the Create a new API Key button
  2. Enter the name for the new API Key

auth4

info

Now select authentication method: API Key or OAuth 2.0

API Key

  1. Note down the generated API Key is marked in the green box.

auth5

Check the example:

Copy
Copied
X-API-KEY: ZHNmd2Ratc2dzZ2RZ3NWqZHNnc2c2Rndmnc2dmZHazZ3NnZzZ3anZHM=
  1. Click the checkbox to confirm saving the API key and close the window.
warning

The generated API Key will be presented only once! The key cannot be recovered in case of loss. Consider saving Client ID , Client Secret as well.

  1. Go back to a desired API section in Developer-Portal

auth6

  1. Copy the provided API Key and paste it to the security box in the console

auth7

  1. Set needed parameters and try it!

OAuth 2.0

  1. Note down the generated Client ID and Client Secret are marked in the green box.

auth3

Check the example:

Copy
Copied
Client ID: f1096473-7g01-42fa-b1c5-e747b987da61
Client Secret: 5eg123cf6sp0g
  1. Click the checkbox to confirm saving the API key and close the window.
warning

The generated Client IDand Client Secret will be presented only once! The credentials cannot be recovered in case of loss. Consider saving API-KEY as well.

  1. Fetch token via token endpoint

In OAuth 2.0 approach, you must generate authentication token first.

  • Use the below data in the API Client of your choice:
Environment Method Token Endpoint
Production POST https://id.cdq.com/auth/realms/cs/protocol/openid-connect/token
Name Sent as Value
Content-Type Header application/x-www-form-urlencoded
Authentication Header "Basic " + Base64(<Client Id>:<Client Secret>)
grant_type Parameter (body) client_credentials

Example using cURL:

Copy
Copied
curl -X POST \ https://id.cdq.com/auth/realms/cs/protocol/openid-connect/token
     -H "Content-Type: application/x-www-form-urlencoded" \
     -d 'grant_type=client_credentials' \
     -u "<Client Id>:<Client Secret>" \

Example using Insomnia:

  • Add a new POST request with the token endpoint address
  • In the request body select Form URL Encoded
  • Set grant_type parameter to client_credentials

oauth20 1

  • Set authentication to Basic Auth and provide Client ID as a username and Client Secret as a password.

oauth20 3

  • Add Header Content-Type with application/x-www-form-urlencoded value.

oauth20 4

  • Hit Send

Successful response:

Copy
Copied
{
	"access_token": "eyJhbG...HSmgnS_0",
	"expires_in": 1800,
	"token_type": "Bearer",
}
Important parameters
  • access_token - long string to be used in the API authentication
  • expires_in - expiration time of token in seconds
  • token_type - token type to be set in the API authentication
  1. Use the authentication token
    • Select one of many CDQ's endpoints and use the below data with the new request
    • Add token to every request towards CDQ, Authentication: Bearer

Example using cURL:

Copy
Copied
curl -X GET \ https://api.cdq.com/requiredapi
     -H "Authorization: Bearer eyJhbG...HSmgnS_0" \

Example using Insomnia:

  • Add a new request with the required endpoint address
  • Set authentication to Bearer and provide access_token value as a token.

oauth20 6

  • Hit Send

Successful response:

oauth20 7

In the case of 403 Forbidden response check your access_token.

oauth20 8

info

Make sure you copied the access_token value without question marks.

Basic Authentication

Deprecated method

CDQ doesn't recommend using Basic Authentication Header Generator for authorization anymore.

Your opinion matters!

We are constantly working on providing an outstanding user experience with our products. Please share your opinion about this tutorial!

Mail our developer-portal team: developer-portal@cdq.com