How to Consume an API (Client Credentials)

Exchange your client credentials for a short-lived access token and use it to call the 9fin API.

Authentication during the transition

9fin is transitioning its APIs from static API keys to a client-credentials authentication strategy. During this transition, some APIs will continue to use API keys, while others will require a client_id and client_secret.

Follow the authentication method documented for the API you are consuming:

  • If you were issued an API key, continue to use the API key authentication flow.
  • If you were issued a client ID and client secret, follow the client-credentials flow on this page.

With client-credentials authentication, you exchange your client_id and client_secret for a short-lived access token. You then send that token as a bearer credential when calling the API.

The client secret is the long-lived credential and does not expire unless it is rotated or revoked. The access token is short-lived and remains valid for one hour.


1. Get your credentials

  1. Sign in to the Kong Dev Portal using your external developer account.
  2. Create an application from My Applications.
  3. Copy your client_id and client_secret when they are displayed. The client secret is shown only once, when the application is created.

Store your client secret securely. Do not include it in source code, logs, or client-side applications.


2. Exchange your credentials for an access token

Token endpoint:

https://api.9fin.com/oauth/token

CLIENT_ID='<from the Dev Portal>'
CLIENT_SECRET='<from the Dev Portal>'

TOKEN=$(curl -sS -X POST \
  https://api.9fin.com/oauth/token \
  -u "$CLIENT_ID:$CLIENT_SECRET" \
  -d grant_type=client_credentials \
  | jq -r '.access_token')

The -u option sends the credentials using client_secret_basic.

client_secret_post is also supported. To use it, send the credentials in the request body instead:

TOKEN=$(curl -sS -X POST \
  https://api.9fin.com/oauth/token \
  -d grant_type=client_credentials \
  -d client_id="$CLIENT_ID" \
  -d client_secret="$CLIENT_SECRET" \
  | jq -r '.access_token')

Do not send scope=openid. Although the authentication strategy declares it, the client_credentials grant rejects it.

A successful response looks like this:

{
  "access_token": "...",
  "expires_in": 3600,
  "token_type": "bearer"
}

3. Call the API

Send the access token in the Authorization header:

curl -sS \
  -H "Authorization: Bearer $TOKEN" \
  https://api.9fin.com/<api-path>

4. Refresh the token

Access tokens remain valid for one hour (expires_in: 3600).

There is no refresh token. The client_credentials grant does not issue one, so the response will not contain a refresh_token field. To obtain a new access token, repeat step 2.

Refresh the token proactively—about one minute before it expires—instead of waiting for a 401 response. This helps prevent intermittent failures caused by clock skew or requests that are still in flight when the token expires.