Forums

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

How to parameterize api_token in atlassian.bitbucket.cloud instance?

Automation December 1, 2025

Hi, I'm using the atlassian cloud api library to retrieve and create bitbucket repositories.

For the authentication, bitbucket is planning to deprecate the password and using the api_token instead.
https://id.atlassian.com/manage-profile/security/api-tokens

If I am reusing the following python snippet to instantiate the bitbucket cloud object, how do I modify it to use the api_token instead? The code is returning 401 error if I use the generated api_token as the password parameter.

 


from atlassian.bitbucket.cloud import Cloud

cloud = Cloud(
    url=url,
    username=username,
    password=password        # Using api_token https://id.atlassian.com/manage-profile/security/api-tokens
)

codespace = cloud.workspaces.get(workspace)    # Returns 401 unauthorized for https://api.bitbucket.org/2.0/workspaces/{workspace}

1 answer

0 votes
David Nickell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 1, 2025

I've adopted two "terms" which may or may not be official/accurate:

  1. an API Token is what you get from the profile security link you shared
  2. an API Key is what happens when you encode your userid, a colon, and the API Token you were provided.

Authentication occurs when you put "Basic <your key>" in an Authorization header

I don't speak python, but here is the Powe Query Code:

Base_URL = P_BaseURL,
Email = P_UserEmail,
Token = P_APIToken,
LocalAPIKey = "Basic " & Binary.ToText(Text.ToBinary(Email & ":" & Token), BinaryEncoding.Base64),

Hope this helps

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events