Language

Application access token actions

The API allows one to revoke a specific access token, rendering it unusable.

Revoking an application access token

In order to revoke an access token, 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/revoke

The request is sent to the token endpoint with the following form-encoded parameters:

Request parameters
ParameterRequiredTypeDescription
client_idyesstringApplication key. Navigate to https://app.kopokopo.com/applications (production) or https://sandbox.kopokopo.com/applications (Sandbox) for your application key
client_secretyesstringApplication secret. Navigate to https://app.kopokopo.com/applications (production) or https://sandbox.kopokopo.com/applications (Sandbox) for your application secret.
tokenyesstringThe access token to be revoked.

Example request

POST https://sandbox.kopokopo.com/oauth/revoke
Content-Type: application/x-www-form-urlencoded

client_id=CGQXLrlfuOqdUYdTcLz3rBiCZQDRvdWIUPkwasGMuGhkem9Bo&client_secret=g7QLwvO37aN2HoKx1amekWi8a2g7AIuPbD5CcJSLqXIcDOxfTr&token=your_access_token
import k2connect

k2connect.initialize(CLIENT_ID, CLIENT_SECRET, BASE_URL) 
token_service = k2connect.Tokens

# request the access token
access_token_request = token_service.request_access_token()

# get access token
access_token = token_service.get_access_token(access_token_request)

# revoke access token
access_token = token_service.revoke_access_token(access_token)
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
    .revokeToken({accessToken: 'my_acccess_token'})
    .then(response => {
        // response is empty when successful
        console.log(response)
    })
    .catch( error => {
        console.log(error)
    })
k2_token = K2AccessToken.new(CLIENT_ID, CLIENT_SECRET)
access_token = k2_token.request_token
k2_token.revoke_token(access_token)
<?
//Including the kopokopo sdk
use Kopokopo\SDK\K2;

// Do not hard code these values
$options = [
    'clientId' => 'YOUR_CLIENT_ID', 
    'clientSecret' => 'YOUR_CLIENT_SECRET',
    'apiKey' => 'YOUR_API_KEY',
    'baseUrl' => 'https://sandbox.kopokopo.com'
];

$K2 = new K2($options);

$tokens = $K2->TokenService();

// Use the service
$result = $tokens->revokeToken(['accessToken' => 'my_access_token']);
if($result['status'] == 'success'){
    // If successful, data will be empty
    $data = $result['data'];
}