GiftCards
Search…
Get an access token
Before you can make a successful request to the GiftCard API, you will need an access token. Reloadly uses the OAuth 2.0 authentication protocol to allow users to prove their identity.
The first step to getting an access token is to retrieve your client credentials. These are specifically created when you sign up for an account. You can access them on your dashboard by navigating to the Developers > API settings section.
Your API client ID and secret are strictly confidential and should not be shared with anyone or exposed during usage
Next, make a request to Reloadly's servers using your Client ID and secret. The HTTP method below describes how you can make this request successfully.
post
https://auth.reloadly.com
/oauth/token
Access token

Request samples

cURL
C#
Golang
Java
Node JS
PHP
Python
1
curl --location --request POST 'https://auth.reloadly.com/oauth/token' \
2
--header 'Content-Type: application/json' \
3
--data-raw '{
4
"client_id": "YOUR_CLIENT_ID_HERE",
5
"client_secret": "YOUR_CLIENT_SECRET_HERE",
6
"grant_type":"client_credentials",
7
"audience":"https://giftcards.reloadly.com"
8
}'
Copied!
1
using System;
2
using System.Threading.Tasks;
3
using System.Net.Http;
4
using System.Text;
5
using Newtonsoft.Json;
6
7
namespace WebAPIClient {
8
class Program {
9
10
static async Task Main(string[] args) {
11
await ApiCall();
12
}
13
14
private static async Task ApiCall() {
15
var json = JsonConvert.SerializeObject(new {
16
client_id = "YOUR_CLIENT_ID_HERE",
17
client_secret = "YOUR_CLIENT_SECRET_HERE",
18
grant_type = "client_credentials",
19
audience = "https://giftcards.reloadly.com"
20
});
21
22
var message = new HttpRequestMessage(HttpMethod.Post, "https://auth.reloadly.com/oauth/token"){
23
Content = new StringContent(json, Encoding.UTF8, "application/json")
24
};
25
26
message.Headers.TryAddWithoutValidation("Authorization", "Bearer YOUR_ACCESS_TOKEN_HERE");
27
message.Headers.TryAddWithoutValidation("Accept", "application/com.reloadly.topups-v1+json");
28
29
using
30
var httpClient = new HttpClient();
31
var response = await httpClient.SendAsync(message);
32
var responseBody = await response.Content.ReadAsStringAsync();
33
var result = JsonConvert.DeserializeObject < dynamic > (responseBody);
34
35
Console.WriteLine(result);
36
}
37
38
}
39
}
Copied!
1
package main
2
3
import (
4
"fmt"
5
"strings"
6
"net/http"
7
"io/ioutil"
8
)
9
10
func main() {
11
12
url := "https://auth.reloadly.com/oauth/token"
13
method := "POST"
14
15
payload := strings.NewReader(`{
16
"client_id":"YOUR_CLIENT_ID_HERE",
17
"client_secret":"YOUR_CLIENT_SECRET_HERE",
18
"grant_type":"client_credentials",
19
"audience":"https://giftcards.reloadly.com"
20
}`)
21
22
client := &http.Client {
23
}
24
req, err := http.NewRequest(method, url, payload)
25
26
if err != nil {
27
fmt.Println(err)
28
return
29
}
30
req.Header.Add("Content-Type", "application/json")
31
32
res, err := client.Do(req)
33
if err != nil {
34
fmt.Println(err)
35
return
36
}
37
defer res.Body.Close()
38
39
body, err := ioutil.ReadAll(res.Body)
40
if err != nil {
41
fmt.Println(err)
42
return
43
}
44
fmt.Println(string(body))
45
}
Copied!
1
OkHttpClient client = new OkHttpClient().newBuilder()
2
.build();
3
MediaType mediaType = MediaType.parse("application/json");
4
RequestBody body = RequestBody.create(mediaType, "{\n\t\"client_id\":\"YOUR_CLIENT_ID_HERE\",\n\t\"client_secret\":\"YOUR_CLIENT_SECRET_HERE\",\n\t\"grant_type\":\"client_credentials\",\n\t\"audience\":\"https://giftcards.reloadly.com\"\n}");
5
Request request = new Request.Builder()
6
.url("https://auth.reloadly.com/oauth/token")
7
.method("POST", body)
8
.addHeader("Content-Type", "application/json")
9
.build();
10
Response response = client.newCall(request).execute();
Copied!
1
var request = require('request');
2
var options = {
3
'method': 'POST',
4
'url': 'https://auth.reloadly.com/oauth/token',
5
'headers': {
6
'Content-Type': 'application/json'
7
},
8
body: JSON.stringify({
9
"client_id": "YOUR_CLIENT_ID_HERE",
10
"client_secret": "YOUR_CLIENT_SECRET_HERE",
11
"grant_type": "client_credentials",
12
"audience": "https://giftcards.reloadly.com"
13
})
14
15
};
16
request(options, function (error, response) {
17
if (error) throw new Error(error);
18
console.log(response.body);
19
});
Copied!
1
<?php
2
3
$curl = curl_init();
4
5
curl_setopt_array($curl, array(
6
CURLOPT_URL => 'https://auth.reloadly.com/oauth/token',
7
CURLOPT_RETURNTRANSFER => true,
8
CURLOPT_ENCODING => '',
9
CURLOPT_MAXREDIRS => 10,
10
CURLOPT_TIMEOUT => 0,
11
CURLOPT_FOLLOWLOCATION => true,
12
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
13
CURLOPT_CUSTOMREQUEST => 'POST',
14
CURLOPT_POSTFIELDS =>'{
15
"client_id":"YOUR_CLIENT_ID_HERE",
16
"client_secret":"YOUR_CLIENT_SECRET_HERE",
17
"grant_type":"client_credentials",
18
"audience":"https://giftcards.reloadly.com"
19
}',
20
CURLOPT_HTTPHEADER => array(
21
'Content-Type: application/json'
22
),
23
));
24
25
$response = curl_exec($curl);
26
27
curl_close($curl);
28
echo $response;
Copied!
1
import requests
2
import json
3
4
url = "https://auth.reloadly.com/oauth/token"
5
6
payload = json.dumps({
7
"client_id": "YOUR_CLIENT_ID_HERE",
8
"client_secret": "YOUR_CLIENT_SECRET_HERE",
9
"grant_type": "client_credentials",
10
"audience": "https://giftcards.reloadly.com"
11
})
12
headers = {
13
'Content-Type': 'application/json'
14
}
15
16
response = requests.request("POST", url, headers=headers, data=payload)
17
18
print(response.text)
Copied!

Response Parameters

Parameter
Type
Description
access_token
string
This indicates your access token
scope
string
The actions and permissions that are granted to your access token
expires_in
integer
The amount of time (in seconds) your access token is expected to last before it expires
token_type
string
Indicates the authorization type of the token