LoginSignup
4
1

More than 1 year has passed since last update.

sourceTreeでBitbucketにpushしようとして認証エラー

Posted at

sourceTreeでBitbucketにpushしようとして認証エラーになりました。

2日前まで、できていて設定は変更してないはずですが、なぜか下記のエラーが起こるようになりました。
仕事で使っているアカウントなので、Bitbucket側の設定が何か変更になったのかもしれませんが、とりあえずエラーメッセージのURLを読んでみました。

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 origin refs/heads/xxxx:refs/heads/xxxx 
Pushing to https://bitbucket.org/xxxxxxx.git
remote: Bitbucket Cloud recently stopped supporting account passwords for Git authentication.
remote: See our community post for more details: https://atlassian.community/t5/x/x/ba-p/1948231
remote: App passwords are recommended for most use cases and can be created in your Personal settings:
remote: https://bitbucket.org/account/settings/app-passwords/
fatal: Authentication failed for 'https://bitbucket.org/xxxxxxx.git/'
Completed with errors, see above

https://atlassian.community/t5/x/x/ba-p/1948231
ここでこの件について説明されているようです(英語)。

https://bitbucket.org/account/settings/app-passwords/にアクセスすると、bitbucketのアプリパスワードを設定する画面が表示されます。

いろいろ調べた結果、アカウント&パスワードでの認証ではダメで、このアプリパスワードをbitbucketで作成して、それをsourceTreeにも設定しないといけないようです。たぶん。

・アプリパスワードの設定方法についての説明
https://support.atlassian.com/ja/bitbucket-cloud/docs/app-passwords/

ここで、アプリパスワードを作成する際に、「このアプリ パスワードに与えるアクセス権と権限を指定します」としか書いてありませんが、権限で「アカウント」を追加しないといけないようです。
最初、それなしでリポジトリの読み書きだけで作ったら失敗しました。

アプリパスワードの設定は修正はできないので、設定を変えたい場合は削除して新しく作ります。
パスワードは一度しか表示されないので、わからなくなってしまったら、また削除して作り直す以外ありません。

権限:アカウント(全部チェック)、リポジトリ(読み書き管理)、プルリクエスト(読み書き)

私は上記の権限を追加してpushできるようになりました。
(pushするのにプルリクエストはいらないと思いますがつけてみました)

bitbucketでアプリパスワードを作り
sourceTreeの環境設定→アカウント→追加、でアカウントを下記のように作成しました。

認証タイプ:Basic
ユーザー名:bitbucketのPersonal settings→アカウント設定→Bitbucket プロフィール設定→ユーザー名のところにあるもの
パスワード:アプリパスワードで表示されたもの
プロトコル:HTTPS

これで接続できました。
プロトコルはsshで自分のpcに作ってる公開鍵を設定してもうまくいきました。

ユーザー名がメアドだと思ってましたが違ってて、ユーザー名が何かでちょっとつまずきました。

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