Skip to content

Get an access token

View as Markdown

A system that signs in with OAuth 2.0 Client Credentials exchanges its client ID and client secret for an access token. Call the API with Authorization: Bearer <access_token> until the token expires.

Changes in 2026-09-27

POST /api/v1/oauth/tokenSince 2026-09-27

Authentication

Secret key (Bearer)

Request body

NameTypeRequiredValuesDescription
grant_typestringyesclient_credentials
client_idstringno
client_secretstringno
scopestringno

Response 200

NameTypeRequiredValuesDescription
access_tokenstringyes
token_typestringyesBearer
expires_inintegeryes
scopestringno

Errors

CodeStatusMessage
VAL-001400The request failed validation.
KEY-005401This client system is disabled, so the request is not accepted.
KEY-006401The client system's inbound method does not allow this kind of credential.
KEY-009401The client ID or client secret is invalid.
curl -sS -X POST "https://api.tappay.mn/api/v1/oauth/token" \
  -H "Authorization: Bearer sk_test_YOUR_SECRET_KEY" \
  -H "TapPay-Version: 2026-09-27" \
  -H "Idempotency-Key: $(openssl rand -hex 16)" \
  -H "Content-Type: application/json" \
  -d '{"grant_type":"client_credentials","client_id":"YOUR_CLIENT_ID","client_secret":"YOUR_CLIENT_SECRET"}'
import { TapPay } from '@tappay-mn/node';

const tappay = new TapPay({ apiKey: 'sk_test_YOUR_SECRET_KEY' });
const result = await tappay.oauth.token({
  body: {
    grant_type: 'client_credentials',
    client_id: 'YOUR_CLIENT_ID',
    client_secret: 'YOUR_CLIENT_SECRET',
  },
});
console.log(JSON.stringify(result));
<?php
require 'vendor/autoload.php';

use TapPay\TapPay;

$tappay = new TapPay(['apiKey' => 'sk_test_YOUR_SECRET_KEY']);
$result = $tappay->oauth->token([
    'body' => [
        'grant_type' => 'client_credentials',
        'client_id' => 'YOUR_CLIENT_ID',
        'client_secret' => 'YOUR_CLIENT_SECRET',
    ],
]);
echo json_encode($result);
import json
import tappay

client = tappay.TapPay("sk_test_YOUR_SECRET_KEY")
result = client.oauth.token({
    "body": {
        "grant_type": "client_credentials",
        "client_id": "YOUR_CLIENT_ID",
        "client_secret": "YOUR_CLIENT_SECRET",
    },
})
print(json.dumps(result))
{
  "access_token": "YOUR_ACCESS_TOKEN",
  "token_type": "Bearer",
  "expires_in": 3600
}

Read Get started for the authentication methods.