For authenticating requests with Stampede, we utilise the OAuth 2.0 protocol, specifically using Bearer Tokens. Your integration must include these Bearer Tokens in the request headers to ensure secure and authorised access. This can look like this within your request headers:
Copy authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Curl NodeJs - Axios PHP - Guzzle Python - http.client
Copy curl --location 'https://global.stampede.ai/oauth/token' \
--header 'Content-Type: application/json' \
--data '{
"client_id": "ai.stampede.marketplace.example",
"client_secret": "XXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"grant_type": "client_credentials"
}'
Copy const axios = require('axios');
let data = JSON.stringify({
"client_id": "ai.stampede.marketplace.example",
"client_secret": "XXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"grant_type": "client_credentials"
});
let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://global.stampede.ai/oauth/token',
headers: {
'Content-Type': 'application/json'
},
data : data
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
Copy <?php
$client = new Client();
$headers = [
'Content-Type' => 'application/json'
];
$body = '{
"client_id": "ai.stampede.marketplace.example",
"client_secret": "XXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"grant_type": "client_credentials"
}';
$request = new Request('POST', 'https://global.stampede.ai/oauth/token', $headers, $body);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
Copy import http.client
import json
conn = http.client.HTTPSConnection("global.stampede.ai")
payload = json.dumps({
"client_id": "ai.stampede.marketplace.example",
"client_secret": "XXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"grant_type": "client_credentials"
})
headers = {
'Content-Type': 'application/json'
}
conn.request("POST", "/oauth/token", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))