Authorization
Kopo Kopo uses Oauth2 to allow access to the Kopo Kopo API. You can view the API Authorization guide at our developer portal. Access to the API can be granted on behalf of the user or of the application itself.
The client credentials flow is used when an application needs to obtain permission to act on its own behalf. The application will exchange its client_id, client_secret and
grant_type=client_credentials for an application's access token.
The Kopo Kopo API then expects the application access token to be used to make calls to the Kopo Kopo API on behalf of the application. The Kopo Kopo API expects the application access token to be included in subsequent API calls via the Authorization HTTP header:
Authorization: Bearer {application_access_token_here}
You must replace {application_access_token_here} with your Oauth2 application access token.
The access token is only valid for 1 hour after the created_at date.
Request application authorization
To request application authorization, use this code:
- JSON
- Ruby
- Python
- JavaScript
- PHP
- Dart
# With json, you can just pass the correct header with each request
curl -d "client_id=CGQXLrlfuOqdUYdTcLz3rBiCZQDRvdWIUPkwasGMuGhkem9Bo&client_secret=g7QLwvO37aN2HoKx1amekWi8a2g7AIuPbD5CcJSLqXIcDOxfTr&grant_type=client_credentials"
-H "Content-Type: application/x-www-form-urlencoded"
-H "User-Agent: <product>/<product-version> <comment>"
"https://sandbox.kopokopo.com/oauth/token"
require 'k2-connect-ruby'
# Using K2 Connect, the assumption here is that you have already initialized the API Client
K2Config.set_base_url('sandbox.kopokopo.com')
access_token = K2AccessToken.new('your_client_id', 'your_client_secret').token_request
access_token # => "myApplicationAccessToken"
import k2connect
k2connect.initialize('your_client_id', 'your_client_secret', 'sandbox.kopokopo.com')
token_service = k2connect.Tokens
access_token_request = token_service.request_access_token()
access_token = token_service.get_access_token(access_token_request)
access_token # => "myApplicationAccessToken"
const options = {
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
apiKey: 'YOUR_API_KEY',
baseUrl: 'https://sandbox.kopokopo.com'
}
//Including the kopokopo module
var K2 = require("k2-connect-node")(options)
const TokenService = K2.TokenService
TokenService
.getToken()
.then(response => {
//Developer can decide to store the token_details and track expiry
console.log(response)
})
.catch( error => {
console.log(error);
})
<?
use Kopokopo\SDK\K2;
// Do not hardcode these values
$options = [
'clientId' => 'YOUR_CLIENT_ID',
'clientSecret' => 'YOUR_CLIENT_SECRET',
'apiKey' => 'YOUR_API_KEY',
'baseUrl' => 'sandbox.kopokopo.com'
]
$K2 = new K2($options);
// Get one of the services
$tokens = $K2->TokenService();
// Use the service
$result = $tokens->getToken();
if($result['status'] == 'success'){
$data = $result['data'];
echo "My access token is: ".$data['accessToken'];
echo "It expires in: ".$data['expiresIn'];
}
// Ensure K2ConnectFlutter is initialized
await K2ConnectFlutter.initialize(
baseUrl: 'sandbox.kopokopo.com',
credentials: K2ConnectCredentials(
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
apiKey: 'YOUR_API_KEY',
),
loggingEnabled: true, // Optionally enable logging. This is disabled by default
);
// Get the token service using K2ConnectFlutter
final TokenService tokenService = K2ConnectFlutter.tokenService();
// Get the access token using the token service
final TokenResponse tokenResponse = await tokenService.requestAccessToken();
// Print the response
print("Token response: $tokenResponse");
On success the response has JSON structured like this
- JSON
- Ruby
- Python
- JavaScript
- PHP
- Dart
{
"access_token": "JCGQXLrlfuOqdUYdTcLz3rBiCZQDRvdWIUPkw++GMuGhkem9Bo",
"token_type": "Bearer",
"expires_in": 3600,
"created_at": "2026-04-27T00:09:15+03:00"
}
{
"access_token": "JCGQXLrlfuOqdUYdTcLz3rBiCZQDRvdWIUPkw++GMuGhkem9Bo",
"token_type": "Bearer",
"expires_in": 3600,
"created_at": "2026-04-27T00:09:15+03:00"
}
{
"access_token": "JCGQXLrlfuOqdUYdTcLz3rBiCZQDRvdWIUPkw++GMuGhkem9Bo",
"token_type": "Bearer",
"expires_in": 3600,
"created_at": "2026-04-27T00:09:15+03:00"
}
{
"access_token": "JCGQXLrlfuOqdUYdTcLz3rBiCZQDRvdWIUPkw++GMuGhkem9Bo",
"token_type": "Bearer",
"expires_in": 3600,
"created_at": "2026-04-27T00:09:15+03:00"
}
<?
// The payload from the k2-connect-php SDK will look like this.
[
"status" => "success",
"data" => [
"accessToken" => "JCGQXLrlfuOqdUYdTcLz3rBiCZQDRvdWIUPkw++GMuGhkem9Bo",
"tokenType" => "Bearer",
"expiresIn" => 3600,
"createdAt" => "2026-04-27T00:09:15+03:00"
]
]
{
"accessToken": "JCGQXLrlfuOqdUYdTcLz3rBiCZQDRvdWIUPkw++GMuGhkem9Bo",
"tokenType": "Bearer",
"expiresIn": 3600,
"createdAt": "2026-04-27T00:09:15+03:00"
}
The client credentials flow is the simplest OAuth 2 grant, with a server-to-server exchange of your application’s client_id, client_secret for an
OAuth application access token. In order to execute this flow, you will need to make an HTTP request from your application server, to the Kopo Kopo authorization server.
HTTP Request
POST https://sandbox.kopokopo.com/oauth/token
User-Agent: "< product >/< product-version > < comment >"
Request Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| client_id | yes | string | Application key. Navigate to https://app.kopokopo.com/applications (production) or https://sandbox.kopokopo.com/applications (Sandbox) for your application key |
| client_secret | yes | string | Application secret. Only revealed to the user when creating an application or during regeneration of client credentials. |
| grant_type | yes | string | This must be set to client_credentials. |
Remember — The access token will be needed for all subsequent calls to the Kopo Kopo API. Only one access token is valid at a time.
Revoke application's access token
To revoke an application's access token, use this code:
- JSON
- Ruby
- Python
- JavaScript
- PHP
- Dart
# Pass the correct parameters with each request
curl -H "User-Agent: <product>/<product-version> <comment>"
-F "client_id=9b36d8c0db59eff5038aea7a417d73e69aea75b41aac771816d2ef1b3109cc2f"
-F "client_secret=d6ea27703957b69939b8104ed4524595e210cd2e79af587744a7eb6e58f5b3d2"
-F "token=dbaf9757982a9e738f05d249b7b5b4a266b3a139049317c4909f2f263572c781"
-X POST "https://sandbox.kopokopo.com/oauth/revoke"
require 'k2-connect-ruby'
# Using K2 Connect, the assumption here is that you have already initialized the API Client
K2Config.set_base_url('sandbox.kopokopo.com')
k2_token = K2AccessToken.new('your_client_id', 'your_client_secret')
access_token = k2_token.request_token
k2_token.revoke_token(access_token)
import k2connect
k2connect.initialize('your_client_id', 'your_client_secret', 'sandbox.kopokopo.com')
token_service = k2connect.Tokens
access_token_request = token_service.request_access_token()
access_token = token_service.get_access_token(access_token_request)
token_service.revoke_access_token(access_token)
const options = {
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
baseUrl: 'https://sandbox.kopokopo.com',
apiKey: 'YOUR_API_KEY',
}
// Including the kopokopo module
var K2 = require("k2-connect-node")(options)
const TokenService = K2.TokenService
TokenService
.revokeToken({accessToken: 'my_access_token'})
.then(response => {
// Response will be empty if it is successful
console.log(response)
})
.catch( error => {
console.log(error);
})
<?
use Kopokopo\SDK\K2;
$clientId = 'YOUR_CLIENT_ID'; // use your sandbox app client ID for development
$clientSecret = 'YOUR_CLIENT_SECRET'; // use your sandbox app API key for development
$baseUrl = 'sandbox.kopokopo.com'; // Use appropriate url for the different environments
$K2 = new K2($clientId, $clientSecret, $baseUrl);
// Get one of the services
$tokens = $K2->TokenService();
// Use the service
$result = $tokens->revokeToken(['accessToken' => 'my_access_token']);
if($result['status'] == 'success'){
// Data will be empty if successful
$data = $result['data'];
}
// Ensure K2ConnectFlutter is initialized
await K2ConnectFlutter.initialize(
baseUrl: 'sandbox.kopokopo.com',
credentials: K2ConnectCredentials(
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
apiKey: 'YOUR_API_KEY',
),
loggingEnabled: true, // Optionally enable logging. This is disabled by default
);
// Get the token service using K2ConnectFlutter
final TokenService tokenService = K2ConnectFlutter.tokenService();
// Use the token service to revoke your token
// If the request fails, an exception will be thrown
try {
await tokenService.revokeAccessToken('accessToken');
} catch (exception) {
print('Revoking token failed with exception: $exception');
}
On success a 200 response with an empty body is returned
- JSON
- Ruby
- Python
- JavaScript
- PHP
- Dart
{}
{}
{}
{}
<?
// The payload from the k2-connect-php SDK will look like this.
[
"status" => "success",
"data" => []
]
{}
The request is used to revoke a particular token at a time.
HTTP Request
POST https://sandbox.kopokopo.com/oauth/revoke
User-Agent: "< product >/< product-version > < comment >"
Request Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| client_id | yes | string | Application key. Navigate to https://app.kopokopo.com/applications (production) or https://sandbox.kopokopo.com/applications (Sandbox) for your application key |
| client_secret | yes | string | Application secret. Only revealed to the user when creating an application or during regeneration of client credentials. |
| token | yes | string | The access token belonging to the application that is to be revoked. |
The access token will be unusable for all subsequent calls to the Kopo Kopo API
Request token introspection
To introspect an application access token, use this code:
- JSON
- Ruby
- Python
- JavaScript
- PHP
- Dart
# With json, pass the correct parameters with each request
curl -H "User-Agent: <product>/<product-version> <comment>"
-F "client_id=9b36d8c0db59eff5038aea7a417d73e69aea75b41aac771816d2ef1b3109cc2f"
-F "client_secret=d6ea27703957b69939b8104ed4524595e210cd2e79af587744a7eb6e58f5b3d2"
-F "token=dbaf9757982a9e738f05d249b7b5b4a266b3a139049317c4909f2f263572c781"
-X POST "https://sandbox.kopokopo.com/oauth/introspect"
require 'k2-connect-ruby'
# Using K2 Connect, the assumption here is that you have already initialized the API Client
K2Config.set_base_url('sandbox.kopokopo.com')
k2_token = K2AccessToken.new('your_client_id', 'your_client_secret')
access_token = k2_token.request_token
k2_token.introspect_token(access_token)
import k2connect
k2connect.initialize('your_client_id', 'your_client_secret', 'sandbox.kopokopo.com')
token_service = k2connect.Tokens
access_token_request = token_service.request_access_token()
access_token = token_service.get_access_token(access_token_request)
token_service.introspect_access_token(access_token)
const options = {
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
baseUrl: 'https://sandbox.kopokopo.com',
apiKey: 'YOUR_API_KEY',
}
//Including the kopokopo module
var K2 = require("k2-connect-node")(options)
const TokenService = K2.TokenService
TokenService
.introspectToken({ accessToken: 'my_access_token' })
.then(response => {
//Developer can decide to store the token_details and track expiry
console.log(response)
})
.catch( error => {
console.log(error);
})
<?
use Kopokopo\SDK\K2;
$clientId = 'YOUR_CLIENT_ID'; // use your sandbox app client ID for development
$clientSecret = 'YOUR_CLIENT_SECRET'; // use your sandbox app API key for development
$baseUrl = 'sandbox.kopokopo.com'; // Use appropriate url for the different environments
$K2 = new K2($clientId, $clientSecret, $baseUrl);
// Get one of the services
$tokens = $K2->TokenService();
// Use the service
$result = $tokens->introspectToken(['accessToken' => 'my_access_token']);
if($result['status'] == 'success'){
echo $result['data'];
}
// This feature is not currently available in the Flutter SDK.
// Please use one of the other SDKs (PHP, Ruby, Python, NodeJs) or the REST API.
On success the response has JSON structured like this
- JSON
- Ruby
- Python
- JavaScript
- PHP
- Dart
{
"active": true,
"scope": "",
"client_id": "_9fXMGROLmSegBhofF6z-qDKHH5L6FsbMn2MgG24Xnk",
"token_type": "Bearer",
"exp": 1613384155,
"iat": 1613376955
}
{
"active": true,
"scope": "",
"client_id": "_9fXMGROLmSegBhofF6z-qDKHH5L6FsbMn2MgG24Xnk",
"token_type": "Bearer",
"exp": 1613384155,
"iat": 1613376955
}
{
"active": true,
"scope": "",
"client_id": "_9fXMGROLmSegBhofF6z-qDKHH5L6FsbMn2MgG24Xnk",
"token_type": "Bearer",
"exp": 1613384155,
"iat": 1613376955
}
{
"active": true,
"scope": "",
"client_id": "_9fXMGROLmSegBhofF6z-qDKHH5L6FsbMn2MgG24Xnk",
"token_type": "Bearer",
"exp": 1613384155,
"iat": 1613376955
}
<?
// The payload from the k2-connect-php SDK will look like this.
[
"status" => "success",
"data" => [
"accessToken" => "JCGQXLrlfuOqdUYdTcLz3rBiCZQDRvdWIUPkw++GMuGhkem9Bo",
"active" => true,
"scope" => "",
"clientId" => "_9fXMGROLmSegBhofF6z-qDKHH5L6FsbMn2MgG24Xnk",
"tokenType" => "Bearer",
"exp" => 1613384155,
"iat" => 1613376955
]
]
// This feature is not currently available in the Flutter SDK.
// Please use one of the other SDKs (PHP, Ruby, Python, NodeJs) or the REST API.
It can be used to check the validity of your access tokens, and find out other information such as which user and which scopes are associated with the token. The client secret will not be displayed as that is to remain confidential with the application owner.
HTTP Request
POST https://sandbox.kopokopo.com/oauth/introspect
User-Agent: "< product >/< product-version > < comment >"
Request Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| client_id | yes | string | Application key. Navigate to https://app.kopokopo.com/applications (production) or https://sandbox.kopokopo.com/applications (Sandbox) for your application key |
| client_secret | yes | string | Application secret. Only revealed to the user when creating an application or during regeneration of client credentials. |
| token | yes | string | The access token belonging to the application. |
Request token information
To request information concerning an application's access token, use this code:
- JSON
- Ruby
- Python
- JavaScript
- PHP
- Dart
# With json, you can just pass the correct header with each request
curl -H "Authorization: Bearer access_token"
-H "User-Agent: <product>/<product-version> <comment>"
"https://sandbox.kopokopo.com/oauth/token/info"
require 'k2-connect-ruby'
# Using K2 Connect, the assumption here is that you have already initialized the API Client
K2Config.set_base_url('sandbox.kopokopo.com')
k2_token = K2AccessToken.new('your_client_id', 'your_client_secret')
access_token = k2_token.request_token
k2_token.token_info(access_token)
import k2connect
k2connect.initialize('your_client_id', 'your_client_secret', 'sandbox.kopokopo.com')
token_service = k2connect.Tokens
access_token_request = token_service.request_access_token()
access_token = token_service.get_access_token(access_token_request)
token_service.request_token_info(access_token)
const options = {
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
baseUrl: 'https://sandbox.kopokopo.com',
apiKey: 'YOUR_API_KEY',
}
//Including the kopokopo module
var K2 = require("k2-connect-node")(options)
const TokenService = K2.TokenService
TokenService
.infoToken({accessToken: 'my_access_token'})
.then(response => {
//Developer can decide to store the token_details and track expiry
console.log(response)
})
.catch( error => {
console.log(error);
})
<?
use Kopokopo\SDK\K2;
$clientId = 'YOUR_CLIENT_ID'; // use your sandbox app client ID for development
$clientSecret = 'YOUR_CLIENT_SECRET'; // use your sandbox app API key for development
$baseUrl = 'sandbox.kopokopo.com'; // Use appropriate url for the different environments
$K2 = new K2($clientId, $clientSecret, $baseUrl);
// Get one of the services
$tokens = $K2->TokenService();
// Use the service
$result = $tokens->infoToken(['accessToken' => 'my_access_token']);
if($result['status'] == 'success'){
$data = $result['data'];
echo "My access token is: ".$data['access_token'];
echo "It expires in: ".$data['expires_in'];
}
// This feature is not currently available in the Flutter SDK.
// Please use one of the other SDKs (PHP, Ruby, Python, NodeJs) or the REST API.
On success the response has JSON structured like this
- JSON
- Ruby
- Python
- JavaScript
- PHP
- Dart
{
"resource_owner_id": null,
"scope": [],
"expires_in": 4498,
"application": {
"uid": "_9fXMGROLmSegBhofF6z-qDKHH5L6FsbMn2MgG24Xnk"
},
"created_at": 1613376955
}
{
"resource_owner_id": null,
"scope": [],
"expires_in": 4498,
"application": {
"uid": "_9fXMGROLmSegBhofF6z-qDKHH5L6FsbMn2MgG24Xnk"
},
"created_at": 1613376955
}
{
"resource_owner_id": null,
"scope": [],
"expires_in": 4498,
"application": {
"uid": "_9fXMGROLmSegBhofF6z-qDKHH5L6FsbMn2MgG24Xnk"
},
"created_at": 1613376955
}
{
"resource_owner_id": null,
"scope": [],
"expires_in": 4498,
"application": {
"uid": "_9fXMGROLmSegBhofF6z-qDKHH5L6FsbMn2MgG24Xnk"
},
"created_at": 1613376955
}
<?
// The payload from the k2-connect-php SDK will look like this.
[
"status" => "success",
"data" => [
"accessToken" => "JCGQXLrlfuOqdUYdTcLz3rBiCZQDRvdWIUPkw++GMuGhkem9Bo",
"resourceOwnerId" => null,
"scope" => [],
"expires_in" => 4498,
"applicationId" => "_9fXMGROLmSegBhofF6z-qDKHH5L6FsbMn2MgG24Xnk",
"createdAt" => 1613376955
]
]
// This feature is not currently available in the Flutter SDK.
// Please use one of the other SDKs (PHP, Ruby, Python, NodeJs) or the REST API.
Shows details about the token used for authentication.
HTTP Request
GET https://sandbox.kopokopo.com/oauth/token/info
User-Agent: "< product >/< product-version > < comment >"