Getting 401 HTTP error while authenticating to Bitbucket Cloud REST APIs

Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.

Summary

This knowledge base article outlines the typical cause of receiving the 401 HTTP error during basic authentication to Bitbucket Cloud REST APIs.

Diagnosis

Using a Bitbucket Cloud REST API endpoint with the format below:

curl -v -u some_name@company.com:some_app_password "https://api.bitbucket.org/2.0/workspaces/workspace_id"

The above Curl command resulting the 401 HTTP error:

< HTTP/2 401 
< server: envoy
* Authentication problem. Ignoring this.
< www-authenticate: Basic realm="Bitbucket.org HTTP"

Cause

If you examine the format used in the above Curl command closely, you will notice that the authentication provided was an email and a generated app password. However, this approach will not work because email addresses are not supported as basic authentication for Bitbucket Cloud REST APIs.

You can check Bitbucket Cloud REST API Authentication methods for more information.

Solution

When interacting with Bitbucket Cloud REST APIs through basic authentication, it is recommended to utilize your account's username instead of an email address. This will ensure a seamless and efficient experience while using the platform.

To know your Bitbucket Cloud username:

  • Go to https://bitbucket.org/
  • Click the gear icon on the top right
  • Click Personal Bitbucket settings
  • Under "Bitbucket profile settings", you'll find your username

Once you have your username, use that for your Bitbucket Cloud REST API basic authentication.

curl -u some_username:some_app_password "https://api.bitbucket.org/2.0/workspaces/workspace_id"



Last modified on Jun 29, 2023

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.