Hi everyone, I am new here. So it might be the case that I am missing something. It would be of great help if someone could guide me through the process. I wrote the following python code to try and get a list of all the users associated with my organization:
from atlassian import Bitbucket
import os
class Driver():
def __init__(self):
self.base_url='https://bitbucket.org'
self.username = "admin"
self.app_password = os.environ.get('BITBUCKET_APP_PASSWORD')
self.bitbucket = Bitbucket(
url=self.base_url,
username=self.username,
password=self.app_password
)
def getVendorData(self):
response = self.bitbucket.get_users()
print(response.status_code)
print(response)
I have created the BITBUCKET_APP_PASSWORD for an admin account and have granted it literally all the permissions. Bit when I try to run the `getVendorData` method I get:
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://bitbucket.org/rest/api/1.0/use
rs?limit=25
Note: The app I am working on is still in a testing phase so I am using a free Bitbucket test workspace.
Thank you for your time
I think that the problem is not with the permissions, but your code can't authenticated using the given username and password.
Hello @Ishita Chauhan ,
Welcome to Atlassian Community!
From the logs you have shared seems like this library is trying to use Bitbucket API v1.0 endpoints, which were deprecated a few years ago (see Users endpoint 1.0).
In this case, you would need to use the endpoints available in Bitbucket API v2.0. If your goal is to list all the members within a workspace, the following 2.0 endpoint might be of help :
You can also check all the other available endpoints in the Bitbucket API 2.0 Reference documentation.
Also, I see that in your script you are using the username "admin". The username used in the authentication must be the same username of the account under which you created the app password. You can check the username of your account on the website by clicking on your personal avatar in the top right corner, selecting Personal Settings, and looking for the field Username. This should be the username used in your script.
Hope that helps! Let me know in case you have any questions.
Thank you, @Ishita Chauhan !
Patrik S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.