Personal Access Token deleting itself

I set up a website using GH pages to showcase some of my repos. I had tested previously on with no issues, and I was ready to migrate to Github. However, I found that my personal access token had deleted itself when my page wanted to grab the repo info (similar to this problem). Here’s the code I use to fetch the repo data.

const query = {
  query: "query {user(login:\"Battlesquid\") {bio,repositories(isFork:false, first:100) {nodes {repositoryTopics(first:5) {nodes {topic {name}}}name,description, primaryLanguage {name,color}, languages(first:100) {nodes {name}}}}}}"

const res = await fetch("", {
    method: "post",
    headers: {
      "Content-Type": "application/json",
      "Authorization": "Bearer <TOKEN>",
      "User-Agent": "Battlesquid"
    body: JSON.stringify(query)

How can I fix this issue? Thanks in advance!

Probably you commit the token to your GitHub repo. if its the case Github will remove the token immediately. so you need to set your token as a variable environment in your system.


Personal access token which has not been used for one year is automatically deleted for security reason.


As a security precaution, GitHub automatically removes personal access tokens that haven’t been used in a year.

1 Like