I have a guest user on Azure Active Directory (fully redeemed - invite accepted etc) that I am attempting to add to a Team (in Microsoft Teams) via the Graph API.
Following the documentation I have set all necessary permissions for my app, however I receive a 403 response from my POST request.
{
"error": {
"code": "Forbidden",
"message": "An unknown error has occurred.",
"innerError": {
"date": "2020-12-09T15:52:30",
"request-id": "X-X-X-X-X",
"client-request-id": "XXX-XXX-XX-XXX-XXX"
}
}
}
Here's my decoded MS auth token below confirming the necessary permissions which should allow my call to add a Team member (the app does a few other things too, hence the extra perms):
{
...
"roles" : [ "Teamwork.Migrate.All", "TeamMember.ReadWriteNonOwnerRole.All", "User.ReadWrite.All", "Directory.ReadWrite.All", "TeamMember.ReadWrite.All", "ChannelMember.ReadWrite.All", "GroupMember.ReadWrite.All", "Channel.Create" ],
...
}
Strangely enough if I use the PowerShell module (microsoftteams) it successfully adds this user to the necessary Team. I understand this module uses the Graph API so I'm not sure why a straight forward POST is failing (tried hunting for the modules source code to see what request they are using but had no luck).
For the purpose of finding a solution to this problem I'm just using Postman so I don't have any code to share. I am also able to add channel members (Guests), create channels, etc via the API but this 403 issue only occurs when attempting to add the Guest to the Team.
My POST:
POST https://graph.microsoft.com/v1.0/teams/{TEAM ID}/members
HEADER
{
"Content-Type": "application/json",
"Authorization": "Bearer {TOKEN}"
}
BODY
{
"@odata.type": "#microsoft.graph.aadUserConversationMember",
"roles": ["member"],
"[email protected]": "https://graph.microsoft.com/v1.0/users('{GUEST_MEMBER_ID}')"
}
I have tried both v1.0 and beta endpoints. Both are giving the same 403.
I am happy to provide any further information that may be required.
Any suggestions / information to point me in the right direction would be greatly appreciated.
Thanks.