Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How do you clone a repository from Bit Bucket server using a personal access token?

John Lawlor
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 15, 2018

How do you clone a repository on bit bucket server over https using personal access tokens?

I have tried using x-token-auth but i think that is only for bit bucket cloud.

 

 

1 answer

1 accepted

0 votes
Answer accepted
Mark A.
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 16, 2018

Hey @John Lawlor

It looks like you were able to get this answered via Support Request, but I would like to post that answer and info for others as well. 

Here is an example curl call from our personal access tokens page for Bitbucket Server:

curl -H "Authorization: Bearer MDM0MjM5NDc2MDxxxxxxxxxxxxxxxxxxxxx" 
http://localhost:7990/bitbucket/rest/api/1.0/projects/WORK/repos/my-repo/commits/?until=master

Note that this is only supported via the REST API over Basic Auth (HTTPS) and cannot be used in the Git client.

Cheers,

Mark

John Lawlor
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2018

Hi Mark,

Thanks for your reply. I have used the personal access tokens before with curl but what I was looking for was a method to clone a repository:

git clone https://x-token-auth:{access_token}@bitbucket.org/user/repo.git

It looks like this is only supported in Bitbucket Cloud, not Bitbucket server. 

Regards,

John

Ali_Daw April 20, 2018

When using a personal access token you need to supply your Bitbucket Server username in your git command. I couldn't find this documented anywhere by Atlassian.

git clone https://{username}:{access_token}@yourbitbucket.org/user/repo.git
Like # people like this
stacklynx-lab September 17, 2019

git clone https://{username}:{access_token}@bitbucket.org/user/repo.git if I pass the username like 'user@bitbucket.com' and access_token will be something like this 'Basic XXXXXXX'. Then I am getting an error.

Like # people like this
ali September 17, 2019

I don't know for sure but I'm guessing that you'll need to use the user slug rather than username. That means you'll need either just the "user" bit or the whole thing but with the special character ("@") encoded, probably something like "user%40bitbucket.com"

Like Hua Soon SIM _Akeles_ likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events