Atlassian BitBucket 7.21.21 (Data Center).
Using BitBucket’s official documentation on creating repositories I tried to create a new project via Postman. My request as a cURL:
curl --location 'https://bitbucket.example.com/rest/api/latest/projects'
--header 'Content-Type: application/json'
--header 'Authorization: Bearer $MY_BEARER_TOKEN'
--data '{
"name": "TEST-X-1",
"key": "TEST-X-1"
}'
I get an error when I try to create a BitBucket project using Bearer token (user’s HTTP access token) (status code is 401):
{
"errors": [
{
"context": null,
"message": "You are not permitted to access this resource",
"exceptionName": "com.atlassian.bitbucket.AuthorisationException"
}
]
}
In the global permissions section, the user has been granted Project Creator
permissions. The Project admin
and Repository admin
permissions have been granted for my user’s Bearer token (maximum possible rights).
But when I use the Basic token in the headers (--header 'Authorization: Basic $MY_BASIC_TOKEN'
), automatically generated by Postman at the stage when I tested the same operation with login and password, the project is created successfully (status code is 201).
Other API requests, such as Get, do not produce errors. There are also no errors when creating repositories using API inside an already created BitBucket project when using Bearer token. Raising the user’s global permissions to System admin
didn’t change anything (and is probably redundant).
Vitaly Kondratev is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.