Authentication
Authentication guide for using the Discloud API (how to obtain and safely use your API Token).
⚙️ How It Works
1
2
3
4
📤 Sending the Token
curl -X GET \
-H "api-token: $DISCLOUD_TOKEN" \
https://api.discloud.app/v2/userimport fetch from "node-fetch";
async function getCurrentUser() {
const res = await fetch("https://api.discloud.app/v2/user", {
headers: { "api-token": process.env.DISCLOUD_TOKEN },
});
if (!res.ok) {
console.error("Request failed:", res.status, await res.text());
return;
}
const data = await res.json();
console.log(data);
}// Install first: npm i discloud.app
const { discloud } = require("discloud.app");
async function validateToken() {
try {
const user = await discloud.login("DISCLOUD_API_TOKEN");
console.log("Authenticated user:", user);
} catch (e) {
console.error("Invalid token or network error:", e.message);
}
}🛡 Securing the Token
⚡ Quick Token Verification
📚 Related Endpoints References
Last updated