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
Generating a client_id
& client_secret
You can generate a client_id
& client_secret
by heading to the Stampede dashboard > Marketplace > API Keys > Create New API Key.
From there, you'll be able to create a new client_id
then in return will provide you with a client_secret
. Keep it safe so it saves the hassle...
Generating a Bearer Token (also known as app-only)
Generate a Bearer Token
POST
~/oauth/token
Request Body
200: OK 400: Bad Request
Copy {
"access_token" : string ,
"expires_in" : number ,
"token_type" : "Bearer" ,
"scope" : "ALL:ALL"
}
Copy {
"error" : string ,
"error_description" : string
}
Examples
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" ))
Last updated 6 months ago