Forums

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

Problems with API-Token and CURL

Dirk R
March 17, 2026

I created an API token and selected ALL available scopes
I want to access the "Downloads" section of my repository from a gradle task, which does not work.


For simplifying testing i tried this:

export BITBUCKET_USER="my_email"
export BITBUCKET_TOKEN="my_token"

curl -i -u "$BITBUCKET_USER:$BITBUCKET_TOKEN" \
https://api.bitbucket.org/2.0/user

curl -i -u "$BITBUCKET_USER:$BITBUCKET_TOKEN" \
https://api.bitbucket.org/2.0/myrepo/myapp

Both curl calls present a 401 error.

What I am doing wrong?



1 answer

0 votes
Aron Gombas _Midori_
Community Champion
March 17, 2026

@Dirk R 

Note that for downloads the correct URL is (API end point doc):

https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/downloads

 So the "/repositories/" fragment is missing from your URL!

Also, you need to determine what type of credential you created. If you created an "App Password" (under Personal Settings > App passwords), you must use your Bitbucket username, not your email address. Your Bitbucket username can be found under Personal Settings > Account settings. The curl call would look like:

curl -u "your_bitbucket_username:your_app_password" https://api.bitbucket.org/2.0/user

If instead you created a Repository Access Token or Workspace Access Token (these are found in the repository or workspace settings and have scopes), the authentication works differently. You should use Bearer token authentication:

curl -H "Authorization: Bearer YOUR_TOKEN" https://api.bitbucket.org/2.0/user

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events