Forums

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

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

J P October 22, 2019

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
Daniil Penkin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 22, 2019

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

J P October 22, 2019

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?

Daniil Penkin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 22, 2019

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
J P October 24, 2019

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
AUG Leaders

Atlassian Community Events