0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Githubで2021年8月からのトークン認証で、今回に限ってなぜか失敗してしまう場合の解決方法

Last updated at Posted at 2022-02-14

動作環境

  • Github
  • MacOS

前提

  • Githubではセキュリティー強化のためにパスワード認証が2021年8月13日から廃止されました。
  • このため、Githubへpush, pullするためにはトークンベースの認証、または、SSHベースの認証が必要になりました。
  • このとき、トークンベースの認証をしようとしてgit pullなどを実行した際に、失敗すると以下のようなエラーが表示されます。
  • github公式のお知らせページ

エラーの表示は以下の通り

Username for 'https://github.com': hogehoge
Password for 'https://hogehoge@github.com': 
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: Authentication failed for 'https://github.com/xxxxxxxxx/yyyyyyy.git/'

一般的な解決方法

  • 一般的には、Githugのトークン認証を設定すれば解決します。ブラウザでGithubにアクセスして以下のように設定をすると、トークン認証が成功します。
Click here - https://github.com/settings/tokens

Step 1 - Open GitHub and log in with your credentials.

Step 2 - Click on the Setting menu.

Step 3 - From the Setting menu click on Developer Settings

Step 4 - From the Developer Settings, menu click on Personal access token

Step 5 - From the Personal access token click on the Generate new Token button.

Step 6 - Now fill up required details like Note, Expiration, Select scopes. And then click on Generate Token button.

Step 7 - After that new token has been generated. Copy that generated token and use this token to access Git with username and token.
  • そんなことは、既に知っているが、今回に限ってなぜかエラーになる人のために、この記事を書きました。以下をお読みください。

ここより下はこんな人が対象

  • 上記の内容は既に知っていて、もう過去に何度もgithubのトークン認証を成功させているのに、今回に限ってなぜか失敗する。
  • MacOSで、git pull, git cloneなどが失敗する。
  • トークンの期限が切れているわけではない。
  • トークンの期限が切れているわけではないが、とりあえず新しいトークンを作成して実行してみるも、やはり失敗する。
  • repoにチェックをちゃんと入れている。
  • 他のウェブサイトをいくつも検索したが、トークン認証がうまくいかない原因がわからない。
  • macOSから実行していて、ターミナルからグループで利用しているEC2サーバにsshログインして、git pullをした際に発生している。
  • とっとと仕事を終わらせたい。

解決方法

  • 自分が発見した解決方法は、MacOSのターミナルを一度閉じて、再度ターミナルからgit pullを実行したら解決しました。
    • ターミナルのタブを閉じて、新しいタブから実行しただけでも成功しました。
    • なんともあっけない解決方法ですが、トラブっている最中はそれどころではありません。

KeyChainAccessについて

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?