Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Git Access with API Token

Matthew Soh
Contributor
July 1, 2025

My App Password works for Git when I have the URL in the form

    git clone https://{username}:{app_password}/....

Now that we need to transition to API Tokens, I created one (didn't specify the scope) and tried to use it using all the methods documented and I always get an authentication error. 

    git clone https://{username}:{token}/....

    git clone https://x-bitbucket-api-token-auth:{token}/....

    git clone https://x-token-auth:{token}/....

    git clone -c http.extraHeader='Authorization: Bearer ...'

I made sure to URL encode the token, still it is failing to authenticate. 

Is this even working at this time? 

Thanks
    Matt

 

2 answers

1 accepted

1 vote
Answer accepted
Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 3, 2025

Hi @Matthew Soh 

You'll need to create the API token and specify the scope - this is mentioned in our deprecation documentation:

  1. Click the gear cog icon, select 

    Atlassian Account settings > Security tab > Create and manage API Tokens

  2. Click Create API token with scopes
  3. If you want to be able to push/pull to the repository - you'll need to tick both 

    read:repository:bitbucket and write:repository:bitbucket - clone only would just be read

  4. Perform the clone by executing the command below which includes your username/token in the URL command (you can find your username by clicking the gear cog icon and selecting Personal Bitbucket Settings - it's visible under the Bitbucket Profile Settings heading):
    git clone https://username:APIToken@bitbucket.org/workspaceID/reposlug.git

Please let me know how this goes.

Cheers! 

Ben (Bitbucket Cloud Support)

Matthew Soh
Contributor
July 4, 2025

Thanks, Ben - this works!

I remember trying it before with a scoped token, but I must have chosen the wrong permissions. When that failed, I assumed that omitting the scope would grant all permissions.

 

Like Ben likes this
Matthew Soh
Contributor
July 4, 2025

 The username x-bitbucket-api-token-auth works as well. 

Like # people like this
0 votes
Jordertech Administrator
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 20, 2026

ssh access keys works only for pull requests not push requests

access tokens with scope for read, write are required for push requests both in comand line git and in sourcetree

With access tokens origin url/path has to be set properly for push requests to go through.

set global config user.email as specified during the creation of access token , either using commandline git or through sourcetree gui for example 3cfhyuggbcxffkhhhlkjjhccx@bots.bitbucket.org

set config origin https://x-token-auth@bitbucket.org/{workspace-ID}/{repo-ID}.git either in command line git or in sourcetree, you will be prompted for password , provide the access token as password.

If you are using sourcetree the access token will be saved in your computer keychain and you dont need to provide password everytime it will be automatically picked from your keychain next time you try to push.

In command line git you need to provide access token as password everytime you push which is cumbersome, so try to use sourcetree which is both secure and easy.

It took me whole 3 days to understand the process

 

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events