1
1

More than 3 years have passed since last update.

GitHubのパスワード認証廃止によるエラーに立ち向かう

Last updated at Posted at 2021-08-16

はじめに

とあるお盆の日。
東京オリンピックも終わり、実家で1日中ゴロゴロしながらアニメを見るという人生の無駄使い...。 もとい、充実した時間を過ごしていたころ。

GitHubではパスワード認証が廃止されていました...。
https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/

自分がパスワード認証の廃止に気付いたのは撮り溜めたアニメを消化し、YouTubeのリロードを永遠と繰り返し半ば廃人になりかけていた時。
ふと個人開発中のwebアプリのアイデアが浮かび、編集した後git pushしたところ...謎のエラー

$ git push origin branch名
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: unable to access 'https://github.com/名前/リポジトリ.git/': The requested URL returned error: 403

この時点で半ば心が折れ...パソコンをそっ閉じ...。

教えてGoogle先生!

とはいえエラーを放置するわけにもいかず、とりまGoogle翻訳にかける。
すると以下のようなことが書かれてました

必要なもの

  • 個人アクセストークン
  • キーチェーンアクセスの変更

個人アクセストークン作成

下記のものを参照し取得
https://docs.github.com/ja/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token

※トークンを使用してコマンドラインからリポジトリにアクセスするには、権限設定で[repo] を選択します。

キーチェーンアクセスの変更

まずは「コマンド⌘キー + スペースキー」を押してSpotlightの検索画面を表示し、 ”キーチェーン”と入力してキーチェーンアクセス.appを選択して起動する。
もしくは、Dockの中にあるロケットアイコンLaunchpadを選択し、「その他」のグループの中にある「キーチェーンアクセス」を選択して起動します。
画像01

画像02

1.キーチェーンアクセスを開けたら「github.com」で検索。
2.「種類」「インターネットパスワード」と記載されているレコードを開く。
3.「パスワードを表示」をクリックし、表示されたパスワードを先ほど取得したアクセストークンに置き換えて保存!
画像03
画像04

そしてgit pushへ

$ git push origin branch名

Enumerating objects: 23, done.
Counting objects: 100% (23/23), done.
Delta compression using up to 4 threads
Compressing objects: 100% (20/20), done.
Writing objects: 100% (23/23), 208.62 KiB | 5.21 MiB/s, done.
Total 23 (delta 0), reused 0 (delta 0), pack-reused 0
To https://XXXXX
 * [new branch]      branch名 -> branch名

無事成功しました!

参考にさせていただいた記事

↑上記の2つの記事にはSSH接続による解決方も載ってます。

↑今回使わせて頂いた手法です。

最後に

初めての記事投稿なので至らぬ部分もあると思いますが、同じ問題に直面した方々の助けに少しでもなれたなら幸いです。

1
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
1
1