Building custom solutions that extend, automate, and integrate Microsoft 365 apps.
Thank you for reaching out to Microsoft Q&A Forum and sharing your experience regarding the unauthorized error you are facing with the Microsoft Teams API.
I understand how confusing it is to receive a 401 Unauthorized response even though your application successfully retrieves an access token. This scenario typically suggests that the token is technically valid but lacks the specific authorization required for the Teams resource you are accessing.
I recommend starting your troubleshooting by inspecting your access token using a tool like jwt.ms to verify the internal claims. Please confirm that the audience claim matches the API you are calling, which is usually https://graph.microsoft.com for these requests. You should also check the scopes claim to ensure it explicitly lists the permissions required for the specific action you are trying to perform.
*Disclaimer: This link may reference Microsoft-related content but is not hosted on an official Microsoft domain (such as .microsoft.com). Please note that Microsoft is not responsible for the accuracy, security, or advertising on this site.
Another common cause for this behavior is missing required permission consent. Please navigate to the API Permissions section in your Azure Portal app registration and ensure that the status column shows a green checkmark indicating consent has been granted for your tenant. Since you are using delegated permissions, it is also important to verify that the signed user has a valid Teams license and access to the specific chat or team context.
Please let me know how you get on, as your feedback is valuable to the community.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.