Cannot add guests user to a Team through Graph API

Vaibhav Chaudhari 0 Reputation points
2024-02-26T15:19:27.5966667+00:00

I've attempted to include a Guest User in Teams via the Graph API, but encountered an Access Denied error. Is there something I might be overlooking? Below are the details. Application Permissions Provided: TeamMember.ReadWrite.All delegates permissions TeamMember.ReadWrite.All Application permissions GuestUserId is fetched using below Graph URL: https://graph.microsoft.com/v1.0/users?$filter=userType eq 'Guest URL Used: https://graph.microsoft.com/v1.0/teams/{teams-Id}/members/add Body: { "values": [ { "@odata.type": "microsoft.graph.aadUserConversationMember", "roles": [ "guest" ], "user@odata.bind": "https://graph.microsoft.com/v1.0/users('{guestUserId}')" } ] } Response: "code": "AccessDenied", "message": "An unknown error has occurred.", "target": null, "innerError": null, "details": [] Reference URL: https://learn.microsoft.com/en-us/graph/api/conversationmembers-add?view=graph-rest-1.0&tabs=http

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,774 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sourabh Gupta 800 Reputation points Microsoft Vendor
    2024-03-03T09:23:17.0866667+00:00

    Hi Vaibhav Chaudhari,

    Thanks for reaching out.

    The first thing you need to know is that you must be a global administrator or a team administrator and team owner to add guests to the team, so you must log in as a user with the role of administrator before you can add guest users.

    The guest user you are trying to add must be added in our active directory (Entra) as guest.

    For adding guest user, you can't use the application permission to get the token, However you van use this permission to add member users.

    You need to add TeamMember.ReadWrite.All delegates permissions, for adding a guest user and then you need to use auth code flow to obtain an access token.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.