Authentication API
Authenticate for the apis access_token
API Endpoint
POST /client/authenticate
Request Headers:
Content-Type: application/json
Request Body:
{
"username" : "<email>",
"secretKey": "<your_key>",
"isAPI": true
}
Success Response
Get your APIs access_token from success.data.access_token
{
"success": {
"message":"Authenticated",
"data": {
"success":true,
"expiresAt":1783077877510,
"user": { "username":"email@test.com","scopes":["tme_user"],"isAPI":true },
"ticket":"b1d4b9a9511dd58fb84a9aab9cc2a740",
"access_token":"eyJhbGciO...p_Nlg" // Your APIs Access Token
},
"uuid":"f8623092-a59a-4ceb-bc75-18e59815d5df" // request tag system reference
}
}
Error Response
{
"error": {
"message":"invalid credentials",
"data":{"invalid":true},
"tag":"6181882e-a5a3-4f28-abce-4f24f4905412" // error tag system reference
},
"uuid":"973e8576-b518-419b-84c3-dd0a7467e64d" // request tag system reference
}
curl 'https://apis.xpay.stream/client/authenticate' \
-H 'Content-Type: application/json' \
--data-raw '{"username":"<your_email>","secretKey":"<your_key>", "isAPI": "true" }'
// npm i cross-fetch
const fetch = require("cross-fetch");
const API_URL = "https://apis.xpay.stream/client/authenticate";
const method = "POST";
const headers = { "content-type": "application/json" };
const body = JSON.stringify({
username: "your_email",
secretKey: "your_secret",
isAPI: true
});
fetch(API_URL, { headers, body, method })
.then(async res => await res.json())
.then(result => {
if(result.error) {
console.log("Authentication Error", result);
}
if(result.success) {
// use next on access_token
// to authentication all API Calls
// with Header: Authorization Bearer access_token
const access_token = result.success.data.access_token;
console.log("Authentication Success", result);
}
})
.catch((err) => {
console.error(err);
});
// Example Response
const response = {
"success": {
"message": "Authenticated",
"data": {
"success": true,
"expiresAt": 1728210519128,
"user": {
"username": "admin",
"scopes": [
"tme_admin"
],
"isAPI": false
},
"ticket": "4a5753991ab08f5ac8a4732c286bc7dc",
"access_token": "eyJhbGciOiJIUz...XXnxw"
}
},
"uuid": "38e27ab0-d331-4c63-8f24-e1603739511d"
}
Last updated