Authentication
The APIs in this documentation use OAuth 2.0 authentication. Every request must include an access token. You get this token through an authentication request with your Client ID and Client Secret.
Get an access token
To begin the backend integration, you first need an access token. To get it, you need your Client ID and Client Secret.
Each access token is valid for 60 minutes. Implement a mechanism that automatically retrieves a new token before the current one expires. This keeps your access to the APIs uninterrupted.
To consume the APIs, use the following DNS values for the
host_getnet_api key:- https://api.pre.globalgetnet.com (homologation environment)
- https://api.globalgetnet.com (production environment)
Request example with cURL
curl --location '{{host_getnet_api}}/authentication/oauth2/access_token'
--header 'Content-Type: application/x-www-form-urlencoded'
--header 'Accept: application/json'
--data-urlencode 'grant_type=client_credentials'
--data-urlencode 'client_id={{PUT_YOUR_CLIENT_ID_HERE}}'
--data-urlencode 'client_secret={{PUT_YOUR_CLIENT_SECRET_HERE}}'
1
2
3
4
5
6
curl --location '{{host_getnet_api}}/authentication/oauth2/access_token'
--header 'Content-Type: application/x-www-form-urlencoded'
--header 'Accept: application/json'
--data-urlencode 'grant_type=client_credentials'
--data-urlencode 'client_id={{PUT_YOUR_CLIENT_ID_HERE}}'
--data-urlencode 'client_secret={{PUT_YOUR_CLIENT_SECRET_HERE}}'
Response
{
"access_token": "eyJ0eXAiOiJKV1QiLCJraWQiOiI1amhLMy9xK0ZpK0tTRkIrRUwwN3VhMFYwdGM9Ii...",
"scope": "name-scope:r",
"token_type": "Bearer",
"expires_in": 3599
}
1
2
3
4
5
6
{
"access_token": "eyJ0eXAiOiJKV1QiLCJraWQiOiI1amhLMy9xK0ZpK0tTRkIrRUwwN3VhMFYwdGM9Ii...",
"scope": "name-scope:r",
"token_type": "Bearer",
"expires_in": 3599
}
Request example with Node.js and Axios
const axios = require('axios');
const qs = require('qs');
let data = qs.stringify({
'grant_type': 'client_credentials',
'client_id': '{{client_id}}',
'client_secret': '{{client_secret}}'
});
let config = {
method: 'post',
maxBodyLength: Infinity,
url: '{{host_getnet_api}}/authentication/oauth2/access_token',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'application/json'
},
data : data
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const axios = require('axios');
const qs = require('qs');
let data = qs.stringify({
'grant_type': 'client_credentials',
'client_id': '{{client_id}}',
'client_secret': '{{client_secret}}'
});
let config = {
method: 'post',
maxBodyLength: Infinity,
url: '{{host_getnet_api}}/authentication/oauth2/access_token',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'application/json'
},
data : data
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
Request example with PHP
<?php
$client = new Client();
$headers = [
'Content-Type' => 'application/x-www-form-urlencoded',
'Accept' => 'application/json'
];
$options = [
'form_params' => [
'grant_type' => 'client_credentials',
'client_id' => '{{client_id}}',
'client_secret' => '{{client_secret}}'
]];
$request = new Request('POST', '{{host_getnet_api}}/authentication/oauth2/access_token', $headers);
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
$client = new Client();
$headers = [
'Content-Type' => 'application/x-www-form-urlencoded',
'Accept' => 'application/json'
];
$options = [
'form_params' => [
'grant_type' => 'client_credentials',
'client_id' => '{{client_id}}',
'client_secret' => '{{client_secret}}'
]];
$request = new Request('POST', '{{host_getnet_api}}/authentication/oauth2/access_token', $headers);
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
Next steps
Now that you have completed authentication, continue with these steps:
- Create your first payment transaction: Quickstart: Create a payment
- See all available payment options: Supported payment methods
On this page
Authentication