Hi Team,Api_token I have created with read and write scope.I am trying to access private repository using api curl but it is throwing error.First try using Bearer Auth
G'day Pankaj!
To start using API tokens with Bitbucket Cloud - you'll need to create the API token and specify the scope - this is mentioned in our deprecation documentation:
Click the gear cog icon, select Atlassian Account settings > Security tab > Create and manage API Tokens
Click Create API token with scopes and select Bitbucket Cloud
You’ll now need to define the scopes necessary for the API commands you’re intending to execute. A summary of these for common API operations is as follows - you can find more information on scopes in our API scopes documentation:Repository Operations
GET (Read):
Scope: read:repository:bitbucket
read:repository:bitbucket
Allows viewing repository data, including source code and configurations.
POST/UPDATE (Write):
Scope: write:repository:bitbucket
write:repository:bitbucket
Allows modifying repository data (e.g., updating source, branches, tags, forking).
DELETE:
Scope: delete:repository:bitbucket
delete:repository:bitbucket
Allows deletion of repositories.
Pull Requests
Scope: read:pullrequest:bitbucket
read:pullrequest:bitbucket
Allows viewing pull requests and commenting.
Scope: write:pullrequest:bitbucket
write:pullrequest:bitbucket
Allows creating, updating, approving, declining, and merging pull requests.
Issues
Scope: read:issue:bitbucket
read:issue:bitbucket
Allows viewing, listing, searching, and commenting on issues.
Scope: write:issue:bitbucket
write:issue:bitbucket
Allows creating, updating, transitioning, and deleting issues.
Wikis
GET/POST/UPDATE/DELETE:
Scope: wiki:bitbucket
wiki:bitbucket
Provides both read and write access to wikis (view, create, edit, push, clone).
Snippets
Scope: read:snippet:bitbucket
read:snippet:bitbucket
Scope: write:snippet:bitbucket
write:snippet:bitbucket
Scope: delete:snippet:bitbucket
delete:snippet:bitbucket
Pipelines
Scope: read:pipeline:bitbucket
read:pipeline:bitbucket
Scope: write:pipeline:bitbucket
write:pipeline:bitbucket
Perform the API command by using the API token with either of the sample commands below.Example 1: The API token, along with your Atlassian account email, can be sent as login credentials. For example:
<span data-testid="renderer-code-block-line-1" data-ds--code--row="">curl --request POST \ --url '<a href="https://api.bitbucket.org/2.0/repositories/%7Bworkspace%7D/%7Brepository%7D/commits" target="_blank" rel="nofollow noopener noreferrer">https://api.bitbucket.org/2.0/repositories/{workspace}/{repository}/commits</a>' \ --user '{atlassian_account_email}:{api_token}' \ --header 'Accept: application/json'</span>
Example 2: Alternatively the API token can be sent in a HTTP Authorization header after the Bitbucket email and API token have been base64 encoded. For example:
<span data-testid="renderer-code-block-line-1" data-ds--code--row="">my_credentials_after_base64_encoding=`echo -n '{atlassian_account_email}:{api_token}' | base64` </span><span data-testid="renderer-code-block-line-2" data-ds--code--row="">curl --request POST \ --url '<a href="https://api.bitbucket.org/2.0/repositories/%7Bworkspace%7D/%7Brepository%7D/commits" target="_blank" rel="nofollow noopener noreferrer">https://api.bitbucket.org/2.0/repositories/{workspace}/{repository}/commits</a>' \ --header "Authorization: Basic $my_credentials_after_base64_encoding" \ --header 'Accept: application/json'</span>
Please perform the above and let me know how this goes. If you are still encountering issues, please let me know the scopes you’ve configured, and share the cURL command you’re executing (make sure to censor any credentials as this is a public forum).
Cheers!
- Ben (Bitbucket Cloud Support)
It looks like you're new here. Sign in or register to get started.