Skip to content

Oauth2

| View as Markdown

OAuth 2.0, which stands for “Open Authorization,” is a framework that enables a website or application to obtain access to resources managed by other web applications on a user’s behalf. This protocol focuses on authorization and relies on access tokens. It is a data element that signifies the user’s permission to access specific resources.

https://kraken.airpay.co.in/airpay/pay/v4/api/oauth2
ParameterType ValueDescriptionValue Like
client_id requiredString
(1-20)
A unique identifier provided by the airpay, used as a credential for generating an access token.4b88dc
client_secret requiredString
(1-200)
A confidential key provided by the airpay team, used along with the Client ID to authenticate and generate an access token.51d68722cca2b4bb096262c326bd24bb
merchant_id requiredNumber
(1-20)
airpay merchant identifier.456
grant_type requiredString
(1-50)
Specifies the authentication flow for obtaining an access token.client_credentials
ParameterType ValueDescriptionValue Like
access_token requiredStringA temporary token used to authenticate API requests, obtained using valid client credentials.00f9a570f917aa8a5df6ae532b5b773f71a00a1a
expires_in requiredStringThe duration (in seconds) for which the access token remains valid before expiration.300
scope optionalStringDefines the level of access granted to the access token for specific API resources and actions.null
<?php
$merchant_id = "<merchant_id>";
$client_secret = "<client_secret>";
$client_id = "<client_id>";
$secretKey = '<secretKey>';
$data = array();
$data['client_id'] = $client_id;
$data['client_secret'] = $client_secret;
$data['merchant_id'] = $merchant_id;
$data['grant_type'] = 'client_credentials';
$encdata = encrypt(json_encode($data), $secretKey);
$checksum = checksum($data);
$payload = ['merchant_id'=>$merchant_id,
'encdata' => $encdata,
'checksum' => $checksum
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://kraken.airpay.co.in/airpay/pay/v4/api/oauth2/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $payload
));
$result = curl_exec($curl);
curl_close($curl);
$response = json_decode($result)->response;
$access_token_data = decrypt($response,$secretKey);
HTTP/1.1 200 OK
{
"status_code": "200",
"response_code": "00",
"status": "success",
"message": "Success",
"data": {
"access_token": "00f9a570f917aa8a5df6ae532b5b773f71a00a1a",
"expires_in": 300,
"scope": null
}
}
HTTP/1.1 200 OK
{
"status_code": "400",
"error_code": "903",
"status": "fail",
"message": "Invalid client id or secret",
}