Permissions for Send Message in Channel API Resulting in Unauthorized Errors

Roshan Raj A K 20 Reputation points
2024-11-12T14:58:40.2133333+00:00

Permissions have been added for both delegated and application levels for the Send Message in Channel API, yet an unauthorized error with the error message being -

"Message POST is allowed in application-only context only for import purposes. Refer to https://docs.microsoft.com/microsoftteams/platform/graph-api/import-messages/import-external-messages-to-teams for more details.

is encountered while testing the API with in Postman. In contrast, testing the same API in the Graph Explorer provides a different error response, indicating that two API permissions are not added.

What viable solutions are available for resolving this issue?

Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. CarlZhao-MSFT 46,371 Reputation points
    2024-11-13T03:08:21.8133333+00:00

    Hi @Roshan Raj A K

    As the error message says, application permissions can only be used to import third-party platform messages, not to send messages. To send messages, you must use delegated permissions.

    User's image

    I guess you are using the client credentials flow in Postman, which is a daemon-based authentication flow that will generate an application token and only supports application permissions, so you cannot use this authentication flow to send messages. If you want to send messages in Postman, you should request a user token using a delegated flow with user participation, such as auth code flow.

    Graph Explorer uses the delegated flow by default, which requires your users to log in in the browser and generate a delegated user token, so you can send messages in Graph Explorer.

    User's image

    Hope this helps.

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


0 additional answers

Sort by: Most helpful

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.