Forums

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

bitbucket cloud rest api: list all repositories a user has access to

Rocelito Abano gmail
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 21, 2024

hi,

 

I would like to ask how can I get a list of all repositories a specific user has permissions to.

My goal is, as part of user off-boarding, is to remove all the individual/explicit permission a specific user has in all repositories.

There is this one, but the user is restricted to the caller calling the API (and owner of the credentials).

There is also this one but I need to specify the repository as well.

My organization has 1000+ repos and I don't want to call bitbucket api 1000+ times just to check if the user has access to all of them.

In the UI (Bitbucket> workspace settings > User Directory > (select a user then click View Access) we can see list of repositories that use has permissions to. Hope there's an equivalent in REST API as well.

 

Please help.

Thanks in advance!

1 answer

1 vote
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 23, 2024

Hello @Rocelito Abano gmail and welcome to the Community!

In case you are interested in a consolidated list of the repository permissions of users in a workspace (including inherited permissions from projects), I would suggest using the endpoint List all repository permissions for a workspace.

This endpoint will return an object for each repository permission for all repositories within a workspace.

Permissions returned are effective permissions: the highest level of permission the user has. This does not distinguish between direct and indirect (group) privileges.

Following is an example request to that endpoint filtering by a user whose name contains the word John

https://api.bitbucket.org/2.0/workspaces/WORKSPACE/permissions/repositories?q=user.nickname+%7E+%22John%22

You can modify that query according to the results you are looking for by using filtering, sorting and partial results.

Also, if your end goal is to fully revoke access of a user in the workspace (removing the user from any groups and any direct permission to repositories/projects as well), you will find a remove option by navigating to Workspace Settings > User Directory > in the line of the user you want to remove click on the Tree dot icon > Remove. This will fully remove the user's access to any content on the workspace.

Thank you, @Rocelito Abano gmail !

Patrik S

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events