From 21ed7d0e837d74c1ebd8ada4396f96ce42c14fb1 Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Sat, 13 May 2023 19:25:44 +0200 Subject: Updated 14 files and added 6 files (automated) --- includes/external/pair/reference.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'includes/external/pair') diff --git a/includes/external/pair/reference.js b/includes/external/pair/reference.js index 1d9fd46..16d1653 100644 --- a/includes/external/pair/reference.js +++ b/includes/external/pair/reference.js @@ -43,7 +43,18 @@ ws.on('message', (raw) => { // server as the 'PEH2_SESSION_TOKEN' cookie when making an authenticated request. console.log(`Token: ${data.token.substring(0, 10)}${"*".repeat(data.token.length - 10)}`); // The token is stored in 'data.token', the code above censors all but the first 10 characters. - process.exit(); + // Once you have the token, you can make authenticated requests: + fetch("https://ponies.equestria.horse/api/session", { + // The 'session' endpoint returns information about the current session (name, IPs, dates, ...) + headers: { + Cookie: "PEH2_SESSION_TOKEN=" + data.token // Passing the token as a cookie + } + }).then((res) => { + res.json().then((data) => { // Most (if not all) endpoints return JSON data + console.log(data); + process.exit(); + }); + }); break; case "reject": -- cgit