API to Send Message to teams - Message POST is allowed in application-only context only for import purposes.

2024-07-11T15:46:48.63+00:00

I'm trying to apply this example User's image

but then I got an error message that App only have permission to do migrations, which I don't understand why.

This is how I'm trying to authenticateUser's image

and this is how I am adding the members to start the chat
User's image Which is working pretty good.

The issue is when I try to send messages.

Anyway I try to search how to authenticate using delegated permission, which I only found the interactive method. But this is interactive so a browser will pop out to request a code. As my aim with this app is a full automated solution to send OneOnOne chat messages to warn a specific user in case of issues, because of that I cannot use this method.

Is there any other solution to authenticate and send messages to a chat?

Thanks

Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
10,358 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,343 questions
Microsoft Deployment Toolkit
Microsoft Deployment Toolkit
A collection of Microsoft tools and documentation for automating desktop and server deployment. Previously known as Microsoft Solution Accelerator for Business Desktop Deployment (BDD).
905 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 42,611 Reputation points
    2024-07-12T02:54:10.7333333+00:00

    Hi @Loiro, Joao Filipe Simoes, Vodafone Portugal

    Yes, this is by design, application permissions currently only support importing third-party platform messages and cannot send chat messages.

    To send chat messages, delegated permissions will be the only option. If the interactive authentication flow is not applicable to your context, you can try to authenticate the user using the silent flow (ROPC flow), which requires you to hardcode the user's password.

    User's image

    However, Microsoft does not recommend that you use the ROPC flow. This flow requires a very high degree of trust in the application and carries risks that are not present in other flows. You should only use this flow when other more secure flows aren't viable.


    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.


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.