Forums

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

Forbidden response using OAuth with API at /2.0/repositories/{username}/{repo_slug}/src

Get-Ryan
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!
June 2, 2018

Hello, please forgive any mistakes around terminology. I'm learning rest api usage on my own through trial and error.

I'm trying to build a Powershell module to wrap around the BitBucket API with a focus on just reading source info from repositories for use in automating CI/CD streams. I'm running into an issue with trying to hit the 2.0/repositories/{username}/{repo_slug}/src endpoint. I keep getting a forbidden response.

I'm using OAuth with a consumer. I'm authenticating with the client_credentials grant type. The consumer initially started with all repo permissions, but I also tried expanding it to include all permissions, and continued to get the error. However, I can use the same OAuth token to successfully hit the endpoint when I include the path to a particular folder or file in the repo.

I was trying to hit the endpoint from browsing the api documentation found at: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/src#get

My overall goal in trying to hit this endpoint was to explore how I can parse and iterate through api responses to build a list of available files and their paths within a repo given only the repo name.

Any help would be greatly appreciated.

2 answers

0 votes
Vineet July 17, 2019

I am still facing the same issue. @Bitbucket guys please provide the solution asap.

0 votes
dgancho
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!
August 3, 2018

Facing exactly the same issue.

Have you found a solution?

Get-Ryan
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!
August 4, 2018

Unfortunately not. For my purposes, I already know the branch names of the repo I'm querying for the CI/CD solution, so I went with the URL 2.0/repositories/{username}/{repo_slug}/src/{branchname}. That one works normally.

Though I imagine there would be another endpoint to allow you to obtain a list of branches other than the one returning the forbidden response. You could probably use that to return the list of branches and have the user select from that to then parse through the files in the selected branch with the above endpoint.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events