Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 2
Message 1 of 2

Personal Access Token deleting itself

Solved! Go to Solution.

I set up a website using GH pages to showcase some of my repos. I had tested previously on repl.it 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("https://api.github.com/graphql", {
    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!

 

1 Reply
Highlighted
Solution
Ground Controller Lvl 1
Message 2 of 2

Re: Personal Access Token deleting itself

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.