いろいろやってみるにっき

てきとーに生きている奴の日記

古いエントリのサムネイル画像がリンク切れになってたりするけど、チマチマ修正中


Git操作のトークン認証

git cloneしようとして、エラーになる。このURLを見ろって表示された。

sh-4.2$ sudo git clone https://github.com/専務のリポジトリ/ほげほげ.git
Cloning into 'ほげほげ'...
Username for 'https://github.com': shigeo@弊社ドメイン
Password for 'https://shigeo@弊社ドメイン@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/専務のリポジトリ/ほげほげ.git/'

 

開いてみる。英語なのでGoogleの翻訳機能で翻訳した。

github.blog

あなたが今日する必要があること 

  • 開発者の場合、今日GitHub.comでGit操作を認証するためにパスワードを使用している場合は、混乱を避けるために、2021年8月13日までにHTTPS(推奨)またはSSHキーを介したパーソナルアクセストークンの使用を開始する必要があります。古いサードパーティ統合を使用しているという警告を受け取った場合は、クライアントを最新バージョンに更新する必要があります。
  • インテグレータの場合、中断を回避するために、2021年8月13日までにWebまたはデバイスの認証フローを使用して統合を認証する必要があります。詳細については、OAuthアプリの承認開発者ブログの発表を参照してください。

 

今までGUIありのOSでZIPをダウンロードしてたので気付かなかった。そういえばこの件は専務が言ってたのを思い出した。

 

手順を探した。GitHubのものがあった。

docs.github.com

 

手順通り、Personal access tokensがあった。

f:id:shigeo-t:20210906130633p:plain

 

[Generate new token]があるのでクリック。

f:id:shigeo-t:20210906130707p:plain

 

手順と違ってパスワードを聞いてくる。

f:id:shigeo-t:20210906130815p:plain

 

なんか名前を付けろって書いてあるので名前を付ける。

f:id:shigeo-t:20210906131102p:plain

Expirationは色々選べるが今回はデフォルトで。手順には何も書いてない。

f:id:shigeo-t:20210906131136p:plain

 

スコープは手順に「リポジトリにアクセスするなら[repo]で」って書いてあるのでrepoを選択。

f:id:shigeo-t:20210906131338p:plain


スクロールすると[Generate token]があるのでクリック。

f:id:shigeo-t:20210906131420p:plain


トークンできた。コピーする。

f:id:shigeo-t:20210906131526p:plain

 

git cloneをトークン使ってやってみる。

sh-4.2$ sudo git clone https://github.com/専務のリポジトリ/ほげほげ.git
Cloning into 'ほげほげ'...
Username for 'https://github.com': shigeo@弊社ドメイン
Password for 'https://shigeo@弊社ドメイン@github.com':
remote: Enumerating objects: 190, done.
remote: Counting objects: 100% (190/190), done.
remote: Compressing objects: 100% (141/141), done.
remote: Total 190 (delta 45), reused 173 (delta 30), pack-reused 0
Receiving objects: 100% (190/190), 641.68 KiB | 16.45 MiB/s, done.
Resolving deltas: 100% (45/45), done.
sh-4.2$ ls -las
total 0
0 drwxrwxrwt 11 root   root   298 Sep  6 13:19 .
0 dr-xr-xr-x 18 root   root   257 Jul 21 12:26 ..
0 drwxr-xr-x  8 root   root   194 Sep  6 13:19 ほげほげ

 

今度は通った。めでたしめでたし。

お時間あったら、他のエントリもクリックして頂ければ幸いです。