using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
await GetAccessTokenAsync();
}
static async Task GetAccessTokenAsync()
{
using (HttpClient client = new HttpClient())
{
var content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("grant_type", "client_credentials"),
new KeyValuePair<string, string>("scope", "pay-sdk-api"),
new KeyValuePair<string, string>("client_id", "your-client-id"),
new KeyValuePair<string, string>("client_secret", "your-client-id-secret")
});
var response = await client.PostAsync("https://iam-test.sticitt.co.za/connect/token/", content);
if (response.IsSuccessStatusCode)
{
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
else
{
Console.WriteLine($"Error: {response.StatusCode}");
}
}
}
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpHeaders;
import java.net.http.HttpHeaders;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
public class Main {
public static void main(String[] args) {
getAccessToken();
}
public static void getAccessToken() {
HttpClient client = HttpClient.newHttpClient();
// Build the form data
String formData = "grant_type=client_credentials&scope=pay-sdk-api&client_id=your-client-id&client_secret=your-client-id-secret";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://iam-test.sticitt.co.za/connect/token/"))
.header("Content-Type", "application/x-www-form-urlencoded")
.POST(HttpRequest.BodyPublishers.ofString(formData))
.build();
client.sendAsync(request, HttpResponse.BodyHandlers.ofString())
.thenApply(response -> {
if (response.statusCode() == 200) {
System.out.println(response.body());
} else {
System.out.println("Error: " + response.statusCode());
}
return response;
})
.join();
}
}
<?php
$url = 'https://iam-test.sticitt.co.za/connect/token/';
$data = array(
'grant_type' => 'client_credentials',
'scope' => 'pay-sdk-api',
'client_id' => 'your-client-id',
'client_secret' => 'your-client-id-secret'
);
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data),
),
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) {
// Handle error
echo "Error occurred while making the request.";
} else {
echo $result;
}
?>
const axios = require('axios');
const url = 'https://iam-test.sticitt.co.za/connect/token/';
const data = {
grant_type: 'client_credentials',
scope: 'pay-sdk-api',
client_id: 'your-client-id',
client_secret: 'your-client-secret'
};
const headers = {
'Content-Type': 'application/x-www-form-urlencoded'
};
axios.post(url, new URLSearchParams(data), { headers })
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(`Error: ${error.response.status}`);
});
import requests
url = "https://iam-test.sticitt.co.za/connect/token/"
data = {
"grant_type": "client_credentials",
"scope": "pay-sdk-api",
"client_id": "your-client-id",
"client_secret": "your-client-secret"
}
headers = {
"Content-Type": "application/x-www-form-urlencoded"
}
response = requests.post(url, data=data, headers=headers)
if response.status_code == 200:
print(response.text)
else:
print(f"Error: {response.status_code}")