简体   繁体   English

GitHub API:个人访问令牌自行删除

[英]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:我需要访问 Github GraphQL API,以便每 N 小时永久发出以下请求:

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 .我创建了一个个人访问令牌, 就像这里所说的那样,只有 1 个范围: 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 .但有时,在一些不清楚的情况下,几乎随机(在应用程序执行期间或关闭后),Github API 响应401 Unauthorized
  5. I visit my Settings / Developer settings / Personal access tokens.我访问我的设置/开发人员设置/个人访问令牌。 Last created token disappears.最后创建的令牌消失。
  6. Why?为什么? What am I doing wrong?我究竟做错了什么?

Probably you commit the token to your GitHub repo.可能您将令牌提交到您的 GitHub 存储库。 if its the case Github will remove the token immediately.如果是这种情况,Github 将立即删除令牌。 so you need to set your token as a variable environment in your system.因此您需要将您的令牌设置为系统中的可变环境。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM