I had a working script and for some reason I now get:
/home/username/dev/myproject/myproject-backup/node_modules/@tryghost/admin-api/lib/admin-api.js:463
const toThrow = new Error(props.message);
^
Error [UnauthorizedError]: Invalid token: jwt expired
at /home/username/dev/myproject/myproject-backup/node_modules/@tryghost/admin-api/lib/admin-api.js:463:33
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async /home/username/dev/myproject/myproject-backup/fixUrls.js:103:15 {
context: null,
type: 'UnauthorizedError',
details: null,
property: null,
help: null,
code: 'INVALID_JWT',
ghostErrorCode: null
}
My code:
const GhostAdminAPI = require("@tryghost/admin-api");
const BASE_URL = "myproject.com";
const api = new GhostAdminAPI({
url: `https://${BASE_URL}`,
version: "v5.0",
key: "MyToken",
});
const POST_ID = "MyPostID";
const res = await api.posts.read({ id: POST_ID });
Version: 5.19.0 (docker on render)
I checked the server time and it is correct, also my local PC time.