Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete Group Members does not have the expected API or its API is not documented #21

Open
Steve-MP opened this issue Dec 18, 2020 · 1 comment

Comments

@Steve-MP
Copy link

According to the FusionAuth documentation, there are two ways to remove a user from a group, and both use the URL to pass the request parameters to the FusionAuth API.

Either:
DELETE /api/group/member/{memberId}
or
DELETE /api/group/member?groupId={groupId}&userId={userId}

The method signature for deleteGroupMembers in this library seems designed to accept a JSON request body, but it is not clear how this body should be structured in order to remove a given user from a given group, since the documentation given above does not include removing users from a group using a request body.

@mooreds
Copy link
Contributor

mooreds commented Dec 18, 2020

Hiya,

I agree that this isn't the clearest documentation. Sorry about that. The PHP client library doesn't support the two parameter based delete methods, but does support the request body based methods. These are documented here: https://fusionauth.io/docs/v1/tech/apis/groups/#request-body-4

If you know the user's membership id, you can delete it directly by building json like:

{
  "memberIds": [
    "222b884b-a0a1-4563-a957-89c7c0513e6e",
    "80d474bf-0dee-4009-b793-ec1255693fa3",
    "16d98a8b-4205-4441-8831-7e3f73154134"
  ]
}

If you don't know the membership ids (which I believe is what you are looking for) but do know the group and the user id, you can also remove memberships in that way:

{
  "members": {
    "1188edfc-cef3-4555-910e-181ddf6153c0": [
      
        "578e52df-83e8-48ca-899b-3aefd56e7fc5",
        "0928cf95-34d1-44cc-9114-da68a07e5ff8"
    ]
  }
}

Here's a curl example:

curl -XDELETE -H 'Content-type: application/json' -H "Authorization: $API_KEY" 'http://localhost:9011/api/group/member' -d '
{
  "members": {
    "63437023-6fc7-4f8f-9759-e325c896fef3": 
      [
        "00000000-0000-0000-0000-000000000006"
      ]
    
  }
}'

In PHP the object would look like this:

 $request_object = [
   "members" => [
         "63437023-6fc7-4f8f-9759-e325c896fef3" => [
            "00000000-0000-0000-0000-000000000006" 
         ] 
      ] 
]; 

Note that there is an issue with the docs linked above, they have an extra array between the group id and the list of user ids, but I'll get that fixed.

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants