Bitbucket Git over HTTPS with an API token

Bitbucket Cloud Git over HTTPS needs an API token with repository scopes. The username is the Bitbucket username or a static token username, not your email.

Last updated: October 26, 2026

Bitbucket Cloud removed app passwords. Git over HTTPS needs an API token with repository scopes. Your Atlassian password will not work at the Git password prompt. The username is your Bitbucket username, or one of Atlassian’s static usernames, not your email address and not the token’s label.

The message

remote: You are using an app password for Git over HTTPS
remote: Invalid username or password
fatal: Authentication failed for 'https://bitbucket.org/...'

A 410 on Git operations means an app password was sent after removal. A 401 means the username, token, or scopes are wrong.

Read the username Git actually sent before you create a second token. git config --show-origin --get credential.username is empty on many machines, so the prompt is the only place the username is chosen. The email address on the Atlassian account is not that username. The token label is not that username. If the prompt is skipped, Windows Credential Manager still has an entry and Git never asks. Remove the git:https://bitbucket.org entry, run git fetch again, and type the username and token in that prompt. A token without write:repository:bitbucket can clone and then fail on git push with the same 401. Add the write scope on a new token. Editing an existing token is not available after you leave the create screen, because the secret was shown once.

Create a token that Git can use

In Bitbucket: profile → Account settings → Security → Create and manage API tokens → Create API token with scopes.

  • App: Bitbucket.
  • Scopes for clone: read:repository:bitbucket.
  • Scopes for clone and push: read:repository:bitbucket and write:repository:bitbucket.
  • Set an expiry. The token is shown once.

Do not put the token in a remote URL that you commit, paste into chat, or leave in a shell history you share.

Use it once, on purpose

Atlassian documents three usernames that work with the token as the password:

  • Your Bitbucket username, exactly as shown under profile settings, including case.
  • x-bitbucket-api-token-auth
  • x-token-auth
git clone https://x-bitbucket-api-token-auth@bitbucket.org/WORKSPACE/REPO.git

When Git asks for a password, paste the token. Do not paste the token into the username field, and do not paste your email there. A successful clone is the test. If the clone works and git push then returns 401, the token is missing write:repository:bitbucket. Create a new token with both scopes. The old token cannot gain a scope after you close the create screen. git pull in a repo that is already up to date printing Already up to date only proves the network and credentials for that fetch. It does not prove push scope.

Illustration of a Git password prompt. The password field is empty. No API token is shown.
Illustration. The password prompt receives the API token. No token is shown. This is not a capture from an account.

For a repository you already have:

git remote set-url origin https://x-bitbucket-api-token-auth@bitbucket.org/WORKSPACE/REPO.git
git fetch

Windows keeps prompting

Git Credential Manager stores a bad app password and sends it forever. Remove the Bitbucket entry, then fetch again so the new token is what gets saved.

  1. Open Credential Manager → Windows Credentials.
  2. Remove entries whose address contains git:https://bitbucket.org or bitbucket.org.
  3. Run git fetch and paste the token when asked.

If it still prompts on every command, the helper is not storing anything:

git config --show-origin --get-regexp credential

You want manager (Git Credential Manager), not a helper you set to "" while testing and forgot to put back. Setting credential.helper empty is how you force a prompt. Put the manager back when the token works:

git config --global credential.helper manager

SourceTree on Windows has its own Authentication list. A token saved only in Git will not update SourceTree, and the reverse is also true. Clear both if both prompt.

A token in the URL is not a convenience feature. git remote -v and shell history both keep it. If a token was pasted into a URL, create a new token, delete the old one in Bitbucket, and set the remote back to a URL with no secret.

Check the result

  • git fetch exits 0 without a prompt on the second run.
  • git push of a scratch branch succeeds. Fetch success does not prove write:repository:bitbucket.
  • git remote -v shows a URL with no token in it.

If that does not work

  • The username is your email or the token name. Switch to the Bitbucket username or x-bitbucket-api-token-auth.
  • The token has no repository scope, or it was created for Jira only. Create another Bitbucket-scoped token. You cannot edit scopes afterward.
  • The token expired. Create a new one and replace the saved credential. Do not extend a guess by retrying the old value.
  • An old app password is still in the remote URL (https://user:APPPASSWORD@bitbucket.org/...). Replace the URL. Rotate the token if it was ever in a URL, because URLs land in logs.

References

On this page

Related guides

Related Tools

Related Articles

Related solutions

Need a tool for this ?

Open the free tools — no signup.

FAQs

Innovative Solutions For Modern Needs
Copyright © 2026 Yallasolve. all rights reserved.