Hello Dmytro_dev,
Thank you for reaching to Microsoft Support!
A 403 Forbidden error typically indicates that the client does not have permission to access the requested resource. Here are some possible reasons why you might be encountering this error when trying to add a team owner using the Microsoft Graph API:
- Insufficient Permissions: Even though you have the
TeamMember.ReadWrite.All
permission, it might not be correctly applied or granted admin consent. Double-check the permissions in the Azure portal. Additionally provideDirectory.ReadWrite.All
,Group.ReadWrite.All
scopes. - Role Assignment Issues: The user or application might not have the necessary roles assigned. Ensure that the application has the required roles to perform the operation.
- Token Scope: The access token might not include the necessary scopes. Decode the JWT token (you can use tools like jwt.io) to ensure it contains the correct scopes and roles. Verify that the token includes all scopes.
- User Licensing: The user you’re trying to add as an owner might not have the necessary licenses. Ensure that the user has the appropriate Microsoft 365 licenses.
By following these steps, you should be able to gather more information and fix the root cause of the 403 error.
Hope this helps.
If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.