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

how to get group membership listing from APIs

alex March 15, 2023

I am attempting to use one of the APIs to get a list of users that are members of a specific group.

It appears the /groups endpoint was deprecated in 1.0, and is not available in 2.0 API get, but there is also mention at the below link that the group endpoints are still available (as do a number of other community conversations).  

https://support.atlassian.com/bitbucket-cloud/docs/groups-endpoint/

Does this endpoint still exist?
How can I access it?

% curl -X 'GET' -H "Authorization: Bearer TOKEN" https://api.bitbucket.org/1.0/groups | jq

{
"type": "error",
"error": {
"message": "Token is invalid or not supported for this endpoint."
}
}
%

If it is a matter of permissions, where do those need to be set, as this token has full admin across all available resources for testing this.

1 answer

1 vote
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 16, 2023

Hello @alex ,

Thank you for reaching out to Atlassian Community!

The /1.0/groups endpoint is indeed still available until equivalent endpoints are still under the works for the 2.0 API.

From the error you shared, it seems like the access token you are using is either invalid or does not have the required scopes. 

I was able to get the members of a group by making a request to the group's endpoint as in the following example:

curl -X GET https://api.bitbucket.org/1.0/groups/<workspace>/<groups>/members \

 --header 'Authorization: Bearer ACCESS_TOKEN'

 It's also possible to use Basic authentication by providing your bitbucket account username and an app password :

curl -u USERNAME:APP_PASSWORD  -X GET https://api.bitbucket.org/1.0/groups/<workspace>/<group>/members

 In this case, could you please confirm how exactly are you generating this access token? Is it by using an OAuth consumer

Thank you, @alex !

Patrik S

alex March 17, 2023

Thanks for the reply @Patrik S 

We are generating the token on the Workspace Access Token page:

https://bitbucket.org/company/workspace/settings/access-tokens

No combination of permissions is appearing to work.

We are also set up with SSO through atlassian cloud so basic auth isn't an option.

Really appreciate the time on this as it's the last piece of an audit puzzle :)

Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 21, 2023

Hello @alex 

Unfortunately Workspace, Project, and Repository Access tokens are not currently supported on 1.0 endpoints.

In this case, you would need to either : 

  • Use Oauth by Creating an Oauth Consumer and exchanging it for an access token using Client Credentials Grant. This access token can be used for requests to the 1.0 endpoint.
  • Use basic authentication with your username and App Password:
    Username : your bitbucket username (not email address). You can find the username by accessing https://bitbucket.org/account/settings/ and looking for the field username.
    App Password : you can create an app password following the instructions in this documentation.

    The fact that you are using SSO will not prevent you from using basic authentication, because the app password is not related to the password you use to login in to the UI. 

Let me know in case you have any questions.

Thank you, @alex !

Patrik S

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events