1
1

More than 3 years have passed since last update.

SourceTreeで403が出た時の対処法

Last updated at Posted at 2021-08-16

環境

OS : macOS Big Sur ver11.4
SourceTree : 4.1.2
Git : 2.30.1

発生した事象

SourceTreeでプッシュしようとすると以下のエラーが発生しました。

git --no-optional-locks -c color.branch=false -c color.diff=false -c color.status=false -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree push -v --tags origin refs/heads/master:refs/heads/master 
Pushing to https://github.com/aaa/bbb.git
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/aaa/bbb.git/': The requested URL returned error: 403
Completed with errors, see above

パスワード認証のサポートは2021年8月13日に削除されました。代わりに個人アクセストークンを使用してください。
とあります。

念の為に

再認証したら行るかなっと思って以下を試してみました。
(案の定ダメでしたが。。)

再認証する

①丸に囲まれた「・・・」マークを押下し、アカウントを選択
②「アカウント」タブで「追加」ボタンを押下
③ホストには「GitHub」を選択し、認証タイプは「Basic」とします。
④ユーザー名とパスワード項目が表示されるので、認証情報を入力します。
⑤プロトコルは「HTTPS」を使用しています。
⑤「保存」ボタンを押下

結果、うまく行かなかったので

認証タイプを「OAuth」に変更し、ブラウザ上で認証して再チャレンジ・・・
認証は通るけど、結局プッシュは出来ず。

キーチェーンアクセスからgithubを削除

MacのFinderで「アプリケーション」→「ユーティリティ」→「キーチェーンアクセス」と開いていき、「github.com」となってるものを削除します。
※ログイン、ローカル項目の両方から削除します。

こちらも、解決しませんでした。

エラーメッセージをよく見る

こちらのページを見るようにと促しがあることに気が付きました。
内容を確認すると「githubの設定に二段階認証があるから有効にしなさい」とのこと

二段階認証を有効化

GitHub Docsのページを参考に以下の手順で二段階認証を有効にします。

① githubページのトップページでアカウントメニューの「setting」を押下

② アカウント設定の画面に遷移するので、「Account security」を押下

③ 「Enabled Two-factor authentication」を押下

④ [Set up using an app] をクリックすると、リカバリーコードが表示されるのでダウンロード等して保管します

⑤ リカバリコードを保存したら、Nextをクリック

⑥ 1タイムパスワードの案内が出てくるのでmicrosoft authenticator等を使って認証する

以上の手順で二段階認証が有効になります。

プッシュを再度試す

SourceTreeでプッシュ出来るようになったか試してみます。
しかし、まだエラーが発生している状態でした。
ただ、エラー内容は代わり、以下の通りになりました。

git --no-optional-locks -c color.branch=false -c color.diff=false -c color.status=false -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree push -v --tags origin refs/heads/master:refs/heads/master 
Pushing to https://github.com/aaa/qiita.git
remote: Repository not found.
fatal: repository 'https://github.com/aaa/qiita.git/' not found
Completed with errors, see above

その他、見直す

色々なサイトを参考に試行錯誤した結果、以下の手順で解決出来ました。

① githubページのトップページでアカウントメニューの「setting」を押下

② アカウント設定の画面に遷移するので、「Developer settings」を押下

③ メニューから「Personal access tokens」を選択

④ 「Generate new token」ボタンを押下

⑤ 「Note」に任意の名称を入力、「Select scopes」欄にはrepo、userをチェック

⑥ ⑤の続きで「Generate new token」ボタンを押下するとパスワードが発行されます

⑤ 上記、再認証の手順でパスワードを④で発行したもので認証する

こちらのページが画像つきで参考になりました。

参考文献

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