1
2

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.

ghコマンド用の認証トークン設定

Last updated at Posted at 2020-07-17

久しぶりにghコマンドを叩いたら動かなくなっていたので認証トークンを更新した。
たぶん誤ってトークンを消してしまったのだと思うが、ググるとhubコマンドのトークンの更新方法ばかりが引っかかってトークンの更新方法の記事が見つからなくて少し手間取ったので備忘のためメモ。

こういう状態

$ gh pr status 
HTTP 401: Bad credentials (https://api.github.com/graphql)

ghコマンド用の認証トークンの設定場所

$ vim ~/.config/gh/hosts.yml

github.com:
    user: xxxx
    oauth_token: xxxxxxxxxxxxxxx

トークンの生成は以下を参照
https://docs.github.com/ja/github/authenticating-to-github/creating-a-personal-access-token
必要なスコープはこの3つ
image.png

備考

ググるとhubコマンドのトークンの更新記事が引っかかるので間違えないように注意。
なお、hubコマンド用のトークンの設定場所は以下。

$ vim ~/.config/hub

github.com:
- user: yokohama4580
  oauth_token: d291399733f3d518c48877e84540c9aa4d94fcbc
  protocol: https
1
2
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
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?