Obtain access token

Credentials

Use this endpoint to obtain an access token using Client Credentials or to refresh an existing token.

Parameters

This endpoint takes no path, query or header parameters.

Request body

Content type: application/x-www-form-urlencoded

Field Type Required Description
grant_type string yes The grant type
scope string no Space-separated scopes
client_id string yes Your client ID
client_secret string yes Your client secret
refresh_token string no Required when grant_type is refresh_token

Request example

{
  "grant_type": "client_credentials",
  "scope": "partner-api",
  "client_id": "your-client-id",
  "client_secret": "your-client-secret"
}

Code samples

curl

curl -X POST 'https://sandbox.payme.io/api/oauth2/token' \
  --data-urlencode 'grant_type=client_credentials' \
  --data-urlencode 'scope=partner-api' \
  --data-urlencode 'client_id=your-client-id' \
  --data-urlencode 'client_secret=your-client-secret'

Node.js

const response = await fetch("https://sandbox.payme.io/api/oauth2/token", {
  method: "POST",
  headers: {
    "Content-Type": "application/x-www-form-urlencoded",
  },
  body: new URLSearchParams({
    "grant_type": "client_credentials",
    "scope": "partner-api",
    "client_id": "your-client-id",
    "client_secret": "your-client-secret"
  }),
});

console.log(await response.text());

Python

import requests

response = requests.post(
    "https://sandbox.payme.io/api/oauth2/token",
    data={
        "grant_type": "client_credentials",
        "scope": "partner-api",
        "client_id": "your-client-id",
        "client_secret": "your-client-secret",
    },
)

print(response.text)

PHP

<?php

$ch = curl_init('https://sandbox.payme.io/api/oauth2/token');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/x-www-form-urlencoded',
    ],
    CURLOPT_POSTFIELDS => http_build_query([
        'grant_type' => 'client_credentials',
        'scope' => 'partner-api',
        'client_id' => 'your-client-id',
        'client_secret' => 'your-client-secret',
    ]),
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;

Responses

200 — Successful authentication (success)

Field Type Description
token_type string
access_token string JWT access token
refresh_token string Refresh token
expires_in integer Access token lifetime in seconds
refresh_expires_in integer Refresh token lifetime in seconds
scope string Granted scopes

401 — Unauthorized (error)

Field Type Description
error string
error_description string