IntelliJ IDEA keeps asking for the Bitbucket password
The Git login dialog in a JetBrains IDE comes back when the IDE has nowhere to keep what you typed, or when the helper that does keep it is not the one the IDE asks. Check two settings. Settings | Appearance & Behavior | System Settings | Passwords must not be "Do not save, forget passwords after restart", and Settings | Version Control | Git | Use credential helper decides whether the IDE leaves Git's own credential helper (Git Credential Manager, the macOS Keychain helper) in charge. Whatever is saved must also be right for Bitbucket Cloud: an API token as the password.
1. Where the IDE saves the password
JetBrains' guide to Git remotes says you can configure the IDE to remember your passwords, under Appearance & Behavior | System Settings | Passwords, with three options:
- Native Keychain: "This setting is only available for macOS and Linux."
- KeePass: the IDE's own password file, unlocked with a master password.
- Do not save: "Do not save, forget passwords after restart". With this one the login dialog returns after each restart, as designed.
Windows has no Native Keychain option, so pick KeePass there if you want the IDE itself to remember the login.
The plugin's sign-in is separate from this dialog: Pull Request Inbox for Bitbucket, a plugin for JetBrains IDEs, keeps its own Atlassian API token (or access token) in the IDE's password safe and asks for it once in its settings page.
2. Who handles the login: the IDE or Git's helper
The Git page of the IDE settings has the checkbox Use credential helper: "Select this option if you don't want to override credential helpers, which is the default behavior." In other words, unless you tick it the IDE replaces Git's credential helpers for the commands it runs, shows its own dialog, and saves the result as in step 1. Tick it, and the helper you already use in a terminal answers instead, and "you will be able to authenticate using a credential helper in the Git login dialog". The choices:
- The IDE's own login, remembered (Use credential helper off, Passwords not on "Do not save"): enter the Bitbucket username and the API token once.
- Git's helper (Use credential helper on): Git Credential Manager keeps the login for the terminal and the IDE alike. If the IDE then answers with an old password, clear it in the helper (how to clear the saved password); if the helper name in your Git config is old, see "credential-manager-core is not a git command"; on Linux it also needs a credential store ("No credential backing store has been selected").
A JetBrains support thread shows the conflict: the first push after a Windows startup failed until the user turned "Use credential helper" off and switched the IDE to its own password storage. Pick one of the two owners and keep the other out of the way.
3. Enter what Bitbucket Cloud accepts
A saved login that is wrong asks again too. Over HTTPS, Bitbucket Cloud wants as the user name your Bitbucket username or x-bitbucket-api-token-auth, and as the password an Atlassian API token with scopes for Bitbucket, read:repository:bitbucket to pull and write:repository:bitbucket to push (Using API tokens). Your account password and app passwords no longer work ("error: 410"). In the dialog, type the token where it asks for the password; to put the user name into the remote so that the dialog only asks for the token, use Git | Manage Remotes…:
https://x-bitbucket-api-token-auth@bitbucket.org/<workspace>/<repository>.git
From a terminal, the same change: git remote set-url origin https://x-bitbucket-api-token-auth@bitbucket.org/<workspace>/<repository>.git. An API token also expires (you choose 1 to 365 days when you create it); make a new one when it has (what to send).
4. Or leave passwords out: SSH
With an SSH key in an agent, the IDE has nothing to ask for. Change the remote with Git | Manage Remotes… to git@ssh.bitbucket.org:<workspace>/<repository>.git (the new SSH host); a passphrase prompt is then the key's, not Bitbucket's.
In the IDE
Pull Request Inbox for Bitbucket, a plugin by Lesstep for JetBrains IDEs 2024.1 or later, does not use the Git login dialog or Git's credential helper. It asks for your Atlassian email and an API token (or, for Data Center, a server and an HTTP access token) in Settings | Tools | Pull Request Inbox for Bitbucket and keeps them in the IDE's password safe, so it signs in to Bitbucket's API by itself while Git's login is being sorted out. The review inbox, diffs and discussions are free; approving, commenting and merging are Pro, with a 30-day trial.
Get it on JetBrains Marketplace
Sources
- Git settings: Use credential helper and Set up a Git repository: Passwords (JetBrains)
- Using API tokens and Manage API tokens (Atlassian)
- Git push fails with authorization issue (JetBrains support community thread)
Bitbucket and Atlassian are trademarks of Atlassian; IntelliJ IDEA is a trademark of JetBrains s.r.o. This page is not affiliated with or endorsed by Atlassian or JetBrains.
More: "The requested URL returned error: 410" · "remote: Invalid username or password" · Git Credential Manager and the November 30 change · Bitbucket pull requests in PyCharm · 日本語