voismager
voismager

Reputation: 453

GitHub API: Personal access token removes itself

I need an access to Github GraphQL API in order to permanently make the following request each N hours:

query($ids: [ID!]!) {
rateLimit {
    cost
    remaining
    resetAt
}

nodes(ids: $ids) {
    ... on Repository {
        milestones(last: 100) {
            nodes {
                issues(last: 100) {
                    nodes {
                        closedAt
                        closed
                    }
                }

                state
                dueOn
            }
        }
    }
}
}
  1. I create a personal access token like it is said here with only 1 scope: public_repo.
  2. I copy and paste it to my application properties.
  3. I launch my application, it is working as expected.
  4. But sometimes, under some unclear circumstances, almost randomly (during app execution or after shut down), Github API responses with 401 Unauthorized.
  5. I visit my Settings / Developer settings / Personal access tokens. Last created token disappears.
  6. Why? What am I doing wrong?

Upvotes: 6

Views: 2000

Answers (1)

EL AZIZI Youssouf
EL AZIZI Youssouf

Reputation: 325

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.

Upvotes: 17

Related Questions