References
- /nishio/Accessing-Scrapbox’s-Private-Projects-API
-
I don’t know if there is a way to reset it if this information (SID) is accidentally leaked, so be careful.
- Since leaking it seems to be irreversible, it’s better to use the SID of a sub Google account’s login session.
- If something happens, you can just discard it for now and figure something out.
- /ras/Accessing-Unofficial-Scrapbox-API
script.js
function myFunction() {
const sid = "YOUR_SID";
const cookie = "connect.sid=" + sid;
const userInfoJSON = UrlFetchApp.fetch("https://scrapbox.io/api/users/me", {
method: "get",
headers: {
"Cookie" : cookie
}
});
const userInfoData = JSON.parse(userInfoJSON);
const csrfToken = userInfoData.csrfToken
const response = UrlFetchApp.fetch("https://scrapbox.io/api/page-data/export/blu3mo.json", {
method: 'post',
headers: {
"Cookie" : cookie,
"X-CSRF-TOKEN": csrfToken,
},
muteHttpExceptions : true,
});
Logger.log(JSON.parse(response))
}
- I was struggling because the export part of the above code wasn’t working, but it seems that it has been changed to a GET method (inoue2002).
- /scrapboxlab/api/page-data/export/:projectname.json#61d3a3381280f00000f07eda
- Oh, I see (blu3mo).
- I didn’t notice because it was dependent on scrapbox-std.