I have a SPA, and I am trying to send a message on behalf of a user in Teams via - POST https://graph.microsoft.com/v1.0/teams/{teamid}/channel/{channelid}/messages
through the same.
But I am continuously getting this error -
{
"error": {
"code": "Unauthorized",
"message": "Unauthorized",
"innerError": {
"date": "2020-12-03T06:09:02",
"request-id": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"client-request-id": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
}
}
}
The SPA is build using Azure AD App registrations and the Following API permissions have been given to the app : ChannelMessage.Send (Delegate) , Chat.ReadWrite (Delegate), ChatMessage.Send (Delegate).
The above API works when calling from the Microsoft Graph explorer portal.
I also compared the access token on jwt.io from both Graph Explorer and My Azure AD application and both have the scopes - [ ChannelMessage.Send ] which is required to send a message to a channel
Need help on this if I have missed something out or if I am doing something wrong.