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?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.