Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,463,001
Community Members
 
Community Events
176
Community Groups

Delete/Remove user from bitbucket cloud using Bitbucket API

Mayank I'm New Here Jan 18, 2023

I intend to delete users from the Bitbucket cloud programmatically using the bitbucket api
but can't seem to find the right endpoint,please help me find or provide the right api
also i would like to delete by passing email associated with the account is there a way to do that?

1 answer

0 votes
Patrik S Atlassian Team Jan 19, 2023

Hello @Mayank ,

Currently, you can only remove a user from your bitbucket workspace using the public API endpoint below : 

We have an open feature request to implement the ability to delete users from the workspace, both from the user groups and direct access. You can access the feature using the following link : 

I would suggest you to add your vote there, since this helps both developers and product managers to understand the interest. Also, make sure you add yourself as a watcher in case you want to receive first-hand updates from that ticket. Please note that all features are implemented with this policy in mind.

As a workaround, you can also use the below Python script to remove user access.

 The above script was produced by an individual within our support team and is not directly supported by Atlassian or our Support team as a whole. This is provided on a best efforts basis and is provided AS IS to try to assist you as much as possible. We recommend you have your dev team review it and ensure you understand what it is attempting to accomplish before executing it. If you would like to change or add functionality to the script, feel free to do so at your end.

Thank you, @Mayank .

Patrik S

Mayank I'm New Here Jan 19, 2023

Thankyou,i have one more query , currently using App password to authenticate api access using token but it is not authenticating and sends 404 error on each request i make.
Below is the sample code

# This code sample uses the 'requests' library:
# http://docs.python-requests.org
import requests
import json

url = "https://api.bitbucket.org/2.0/user/permissions/repositories"

headers = {
"Accept": "application/json",
"Authorization": "Bearer <access token>"
}

response = requests.request(
"GET",
url,
headers=headers
)

print(response)
Patrik S Atlassian Team Jan 25, 2023

Hello @Mayank ,

From the snippet you shared, it seems like your code is currently configured to use Bearer tokens in the Authorization header, which requires you to use OAuth 2.0 and get an access token. 

The other type of authentication is called Basic Auth, which uses your bitbucket username and an app password as the credentials for the Authentication head. To use basic auth you will need to configure the headers to be like the below : 

"Authorization": "Basic <encoded credentials>"

Where the <encoded credentials> placeholder needs to be replaced by the base 64 encoded of your bitbucket username and app password separated by a colon.

For example : 

mybbusername:myapppassword

base 64 encoding would generate

bXliYnVzZXJuYW1lOm15YXBwcGFzc3dvcmQ=

And the resulting Authorization header would be

"Authorization": "Basic bXliYnVzZXJuYW1lOm15YXBwcGFzc3dvcmQ="

Hope that helps! Let me know in case you have any questions.

Thank you, @Mayank !

Patrik S

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events