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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Can I list private repos via the API? I so, how?

Hello,

I created a private repository and need to check the contents using the BitBucket API.

Is this possible? If it is, could somebody please outline the steps?

 

Thanks you very much in advance.

1 answer

1 accepted

0 votes
Answer accepted

Hello @J P

Thanks for reaching out.

Yes, it is definitely possible. Here's an endpoint to list repositories under an account (user or team). To include private repositories in the response you need to authenticate your request using one of the methods.

Here's an endpoint to list the root of the repository, and this one is to fetch the content of a file or list a directory at the given path and revision. Similarly, you need to authenticate your requests if you're browsing a private repository.

Hope this helps. Let me know if you have any questions.

Cheers,
Daniil

Hi Daniil,

Your reply is much appreciated. I went to the second link you posted about authentication methods and tried following the instructions for Oauth2.

When trying to follow the https link in section '1. Authorization Code Grant (4.1)'

( https://bitbucket.org/site/oauth2/authorize?client_id={client_id}&response_type=code )

and enter my client id, which I am getting from here ( https://bitbucket.org/!api/2.0/user?access_token={access_token )

I get a message saying "invalid client_id. - This integration is misconfigured. Contact the vendor for assistance."

Any idea why this might be happening?

Hm, I think you got confused by the terms. Client ID for OAuth is the OAuth consumer key which you need to set up first in your Bitbucket settings (Bitbucket Settings → OAuth → OAuth consumers → Add consumer).

The easier way to try out the API is app passwords, so you might want to use them first, and then configure OAuth.

Hope this helps.

Cheers,
Daniil

Like J P likes this

Hey Daniil,

Using app password worked for me, thanks a lot!

 

If anybody in the future wants to know how to use app passwords:

 

https://confluence.atlassian.com/bitbucket/app-passwords-828781300.html

 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

1,804 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you