Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Getting all repositories under the workspace

Hi Guys

im having troubles to generate access token with simple curl ... I need this access token in order to execute 

curl --request GET \ --url '{workspace}' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json'


in the documentation :

i can't find the the curl command for authenticate...

tried to :

 curl --request GET{client_id}&response_type=token


and got : no matches found....


I appreciate any help here




1 answer

0 votes

Hi @Eyal David and welcome to the community!

Please see below the steps to obtain the access token:

1. After you create the OAuth consumer in the Bitbucket workspace, open a tab in your browser and enter the following URL:{consumer_key}&response_type=code

Replace {consumer_key} with the key of the OAuth consumer, no brackets in the URL, and then hit Enter.

If the callback URL you set for the OAuth consumer was e.g. http://localhost, you will get redirected to something like


Copy the code from that URL: fpYPDYsryEpsRawrj4

Please note this step needs to be executed on your browser, it is not possible to obtain the code with curl.

2. You can then obtain an access token by executing the following command

curl -X POST -u "key:secret" -d grant_type=authorization_code -d code=fpYPDYsryEpsRawrj4

Replace key with the consumer's key
Replace secret with the consumer's secret
Replace the code value in there (fpYPDYsryEpsRawrj4) with your code from the previous step

3. The output will include an access_token field and a refresh_token field.

You can use the value of the access token for 2 hours in your API calls before it expires.

You will then have to use the refresh token from the output in step 2 to get a new access token and a new refresh token.

curl -X POST -u "key:secret" -d grant_type=refresh_token -d refresh_token={2Eoiw6UJ707AD9aIyUR}

Replace key with the consumer's key
Replace secret with the consumer's secret
Replace the value of the refresh_token in there (2Eoiw6UJ707AD9aIyUR) with the one from your output in step 3.

This command will give you a new access token and a new refresh token and you can use this command from now on to generate new access and refresh tokens when each access token expires.

If you have any questions, please feel free to let me know.

Kind regards,

@Theodora Boudale Thank you very much for your fast response.

is there a way to get all repositories names under the workspace ?

i'm using :

"curl --request GET \
--url '${workspace}' \
--header 'Authorization: Bearer ${token}' \
--header 'Accept: application/json'"

the json doesn't include the list of repositories under the account .... i used the company name as workspace

any suggestion ?



Hi Eyal,

I would suggest checking first if the OAuth consumer has Read permissions for Repositories (from the workspace's Settings > OAuth consumers > Edit the consumer).

If the permissions look ok, could you please let me know:
1. Did you generate the OAuth consumer for the company workspace? Or for your personal workspace?
2. Do you get no output at all when you run this call?
3. Could you run the curl call with the flag -vv as well and copy-paste the output here?
(Please make sure to remove any sensitive info from the output prior to sharing it, like the access token, x-consumer-client-id, any workspace/repo urls etc)
4. Can you confirm if you are using in the url the workspace ID that can be found here where company-workspace replace with the one of your company's workspace?

I see that you have created a support ticket for this issue as well, so if you don't feel comfortable sharing any of this info here, you can also share it in the support ticket, which is visible only to you and Atlassian staff.

Kind regards,

@Theodora Boudale 

it worked out that i didn't do the pagination ... once did it got all the repositories 



Hi Eyal,

Thank you for the update, I'm glad that you figured this out.

Please feel free to reach out if you ever need anything else!

Kind regards,

@Theodora Boudale 

Thank you very much ! appreciated !

Like Theodora Boudale likes this

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events