👋
【Bitbucket】パスワードを求められてPUSHできないとき
事象
BitbucketにPUSHしようとしたところ、
権限まわりでエラーが起こった。
$ git push origin master
Password for 'https://****@bitbucket.org':
remote: You may not have access to this repository or it no longer exists in this workspace. If you think this repository exists and you have access, make sure you are authenticated.
fatal: Authentication failed for 'https://bitbucket.org/****'
最近アプリパスワードを使うような仕様だったのにもう廃止になった模様。
背景
開発したアプリケーションのソースをBitbucketで管理するためにgit remote add origin {repository}を行った後にPUSHしようとしたところエラーが発生
前までは特になにもせずPUSHできていたはずなのに...
結論
Bitbucket上でAPIキーを発行し、
git remote add origin {repository}の中にAPIキーを含める必要があった。
手順
APIトークン作成
- Atlassian account settingsを選択
- ヘッダーのセキュリティを選択し、画面下部の「APIトークンの作成と管理」
- メール認証が必要なので認証を行ってください
- 「スコープ付きAPIトークンを作成」
API トークンに名前と有効期限を指定し (通常は、トークンを使用するアプリに関連するものを指定する)、[次へ] を選択 - [Bitbucket] を選択し、[次へ] を選択
- API トークンに必要なスコープ (権限) を選択し進む
- 発行されたトークンをコピーし次の手順へ。
APIトークンを使ってPUSHを行う
- git remote add
{api_token}にコピーしたAPIキーを入力してください。
$ git remote add origin https://{bitbucket_username}:{api_token}@bitbucket.org/{workspace}/{repository}.git
- 同じくgit remote set-url originを行う
$ git remote set-url origin https://{bitbucket_username}:{api_token}@bitbucket.org/{workspace}/{repository}.git
これではれてPUSHできました。
そしてこの記事がzenn初投稿です
参考
Discussion