# Ghost Admin API - Invalid token: jwt expired

**URL:** <https://forum.ghost.org/t/ghost-admin-api-invalid-token-jwt-expired/33493>\
**Category:** Integrations & API\
**Created:** [October 16, 2022, 11:07pm UTC](https://forum.ghost.org/t/ghost-admin-api-invalid-token-jwt-expired/33493 "2022-10-16T23:07:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![agam](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/agam/32/16469_2.png) [@agam](https://forum.ghost.org/u/agam)\
**Post date:** [October 16, 2022, 11:07pm UTC](https://forum.ghost.org/t/ghost-admin-api-invalid-token-jwt-expired/33493/1 "2022-10-16T23:07:31Z")

</div>

I had a working script and for some reason I now get:

```auto
/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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![Cathy\_Sarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/cathy_sarisky/32/25750_2.png) [@Cathy\_Sarisky](https://forum.ghost.org/u/Cathy_Sarisky)\
**Post date:** [October 17, 2022, 1:22pm UTC](https://forum.ghost.org/t/ghost-admin-api-invalid-token-jwt-expired/33493/2 "2022-10-17T13:22:27Z")

</div>

It might be worth triple checking that what’s visible on the admin portal for your api key matches the key in this code, and the url matches, too.

---

<div class="post-metadata">

**Author:** ![agam](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/agam/32/16469_2.png) [@agam](https://forum.ghost.org/u/agam)\
**Post date:** [October 17, 2022, 3:52pm UTC](https://forum.ghost.org/t/ghost-admin-api-invalid-token-jwt-expired/33493/3 "2022-10-17T15:52:45Z")

</div>

Yes, I tried to recreate the key several times. Any other ideas?

---

<div class="post-metadata">

**Author:** ![lchaffey](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/lchaffey/32/26763_2.png) [@lchaffey](https://forum.ghost.org/u/lchaffey)\
**Post date:** [October 11, 2023, 3:10pm UTC](https://forum.ghost.org/t/ghost-admin-api-invalid-token-jwt-expired/33493/4 "2023-10-11T15:10:24Z")

</div>

I understand this may be a bit of a late reply to this post (1 year on), but I have just expierenced this exact issue.

My resolution, after about 2 hours of investigation, was to check the time on the server and client machine. The server time was 10 minutes out, and needed to be resynced.
