2
1

GitHubのアクセストークン作成方法と、使い方

Posted at

背景

とあるリポジトリのデバッグを任されたので、久しぶりにgit cloneをしようとしたら

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com

github初心者の僕には何が何だかわからない状態でした。

やるべきこと

この場面に直面したらやるべきことは、アクセストークンを作る!! です。

作り方は、以下に記しておきます。

アクセストークンの作り方

  1. 右上のアカウントマークをクリックして、下の方の ⚙settingをクリック
  2. 左側メニューの1番下にある、<>Developer settingsをクリック
  3. 🔑personal access tokensのTokens (classic)をクリック
  4. 何のトークンかわかる文字をnoteに入れましょう。
  5. Expirationはお好きに。。。。?
  6. Select scopesは、repo 、admin:repo_hook、delete_repoくらいは付けておきましょう。
  7. アクセストークンが表示されるので、どこかに保存しておきましょう! 今後は見れなくなります。

アクセストークンを使って、認証

Username for 'https://github.com': 
Password for 'https://hoge@github.com':

Passwordの欄に、普段使っているパスワードではなく、先ほど作ったアクセストークンを入れます。

最後に

URLに認証情報を入れる方法などもありましたが、Passwordに入力する方が簡単だと思ったので書いておきます。

参考にさせていただいたサイト様

https://qiita.com/setonao/items/28749762c0bc1fbbf502
https://dev.to/shafia/support-for-password-authentication-was-removed-please-use-a-personal-access-token-instead-4nbk#:~:text=Please%20use%20a%20personal%20access%20token%20instead.,-While%20pushing%20some&text=Starting%20from%20August%2013%2C%202021,in%20place%20of%20your%20password.

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