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

How to use access tokens for pull and push code to bitbucket

Sudhansu_Sahoo
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 16, 2023

Hi,

I created an access token with all permission.

Now I want to use it to push and pull code from bitbucket.

I tried using api: I was not able to push folders with it.

thatswhy I used gitpython to do the operations, but it is not asking for access token while pulling and pushing code.

 

I do not use pipelines for this, just normal repositories

Can someone suggest me a workaround for this

1 answer

0 votes
Mark C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 18, 2023

Hi @Sudhansu_Sahoo,

Welcome to the community.

Could you confirm which Access token you're currently using? - https://support.atlassian.com/bitbucket-cloud/docs/access-tokens/

Also, you mentioned you've tried using it against an API but you were not able to push folders with it.
Could you share the API endpoint you're using and the error message you're getting when you've tried that?

Regards,
Mark C

Sudhansu_Sahoo
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 19, 2023

Hi @Mark C ,

Thank you for your response.

 

This is the endpoint i am using: 

* https://api.bitbucket.org/2.0/repositories/godigit/pyops-test-project/src/

here is the data i am sending to the api:

payload = {}
files=[
  ('file.txt',('file.txt',open('/D:/Requirement/pyops_validator/test_folder/new_folder/file.txt','rb'),'text/plain'))
]
headers = {
  'Accept''application/x-www-form-urlencoded',
  'Content-Type''application/x-www-form-urlencoded',
  'Authorization''Bearer <Access token>'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)
Mark C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 16, 2023

Hi @Sudhansu_Sahoo

Could you try to do a CURL command instead and see if it works for you?

You can check some sample CURL commands from this link.

Regards,
Mark C

Suggest an answer

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

Atlassian Community Events