Reputation: 289
I have an Azure Function app that adds and removes users to specific group in Azure AD.
The add code works but when I try to call:
await GraphHelper.graphClient.Groups[groupId].Members[userToRemove.Id].Request().DeleteAsync();
I get error:
Code: Authorization_RequestDenied
Message: Insufficient privileges to complete the operation.
When I check the App Registration used I see that the following permissions are set:
What am I missing?
Update The following code add user to a group does work
await GraphHelper.graphClient.Groups[groupId].Members.References.Request().AddAsync(userToAdd);
Upvotes: 0
Views: 74
Reputation: 289
After investigating and searching more, due to information added by Shiva Keshav Varma, I found the issue.
I needed to add 'RoleManagement.ReadWrite.Directory' as Api permission and change the code.
The code should be:
await GraphHelper.graphClient.Groups[groupId].Members[userToRemove.Id].Reference.Request().DeleteAsync()
I needed to add Reference to the request. I found the answer here Micrsoft documentation
Upvotes: 1