This section will describe how you will authenticate yourself to the N-Genius Online identity services, and receive an access token in return, which you can then use to perform more meaningful operations using the N-Genius Online payment APIs.
Request an access token
The first step for any N-Genius Online gateway interaction is to validate ourselves with the identity service and obtain an access token. This token allows us to execute operations on the gateway APIs with authority, and whilst a single token will expire after 5 minutes, we can use our Service Account API key to generate one at any time.
HTTP Request Method: POST
Resource (URI): https://api-gateway.sandbox.ngenius-payments.com/identity/auth/access-token
Headers:
Add these headers to your request (note that you should replace 'your_api_key' with the service account API key in the Getting started section).
Header | Value |
---|---|
Content-Type | application/vnd.ni-identity.v1+json |
Authorization | Basic your_api_key |
Example response (body):
{
"access_token": "eyJhbGciOiJSUzI1N…0eDloZnVRI",
"expires_in": 300,
"refresh_expires_in": 1800,
"refresh_token": "eyJhbGciOi…eDloZnVRIn0",
"token_type": "bearer"
}
Code example (PHP + cURL):
$apikey = "[your-api-key]"; // enter your API key here
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "<<identityUrl>>auth/access-token");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"accept: application/vnd.ni-identity.v1+json",
"authorization: Basic ".$apikey,
"content-type: application/vnd.ni-identity.v1+json"
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"realmName\":\"<<tenantRealmName>>\"}");
$output = json_decode(curl_exec($ch));
$access_token = $output->access_token;
Note: you will require the access_token value for any subsequent calls to the N-Genius Online platform APIs.