Personal Access Token returns 401 with ‘bad credentials’

Personal Access Token returns 401 with ‘bad credentials’

我使用的个人访问令牌至少有 1 年没有闲置,并且在我的帐户下仍然可见(我想这意味着它没有被自己删除)。但是当我使用它时,它 returns 401 with text 'bad credentials'.

默认个人访问令牌是否有隐藏的有效期? token 本身已经有一年没有被创建了(它大约是在 2~3 个月前创建的)所以它不可能闲置一年。该令牌当时运行良好,但最近停止运行。

顺便说一句,重新生成令牌并用新令牌替换旧令牌后,问题就解决了。只是想知道如何防止这种情况再次发生。

This post 在社区论坛上有一个由 GitHub 支持提供的列表,其中提到了令牌可能失效的可能原因。

  • the token was manually revoked by the user, either via the UI or the API
  • the token was manually revoked by the OAuth application it was created for, either via the UI or the API
  • the token was automatically revoked by GitHub because it has not been used for over a year
  • the token was automatically revoked by GitHub because it was pushed to a public repository – see https://github.com/blog/1956-keeping-github-oauth-tokens-safe (this will happen only for tokens that have some scopes attached, it will not happen for scopeless tokens)
  • the token was automatically revoked by GitHub because the OAuth application it was created for reached the limit for the number of tokens for a specific user and set of scopes – see https://developer.github.com/v3/oauth/#multiple-tokens