Share via

How to develop an MS teams bot with oauth app using graph api

Chris Morris 0 Reputation points
2024-11-20T19:28:44.2466667+00:00

I have setup a small App Registration to work with the Graph API along side MS Teams. It uses the oauth flow to receive an access code, which I then can exchange for a token. I am successfully able to exchange the token for a "bot" token but then receive an error when attempting to send a message to a specific ms teams channel. I have tried the following endpoints using my service url:

  • constructing a conversation reference and sending a request to the v3/conversations/{conversation_id} endpoint but receive {"message":"Authorization has been denied for this request."}
  • constructing a new activity and sending a request to v3/conversations/{conversation_id}/activities but receive {"message":"Authorization has been denied for this request."}
  • attempting to create a new conversation first, also receiving the same error message

I have also added an app to my teams instance and into that channel. I have also inspected the JWT token which includes the necessary TeamWork.Migrate.All . My app also includes numerous application permissions which appear in the JWT. I'm looking for any guidance on what might be missing.

Azure App Service
Azure App Service

Azure App Service is a service used to create and deploy scalable, mission-critical web apps.

Microsoft Security | Microsoft Graph
0 comments No comments

1 answer

Sort by: Most helpful
  1. Achraf Ben Alaya 1,396 Reputation points MVP
    2026-04-02T21:23:56.7766667+00:00

    Hello ,

    you can refer to this page to see detailed documentation

    https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/authentication/add-authentication?wt.mc_id=MVP_328341

    I think you’re using the wrong token type Teams bot messages must be sent with a Bot Framework access token (from your bot’s App ID/secret via Azure Bot Service), not a Graph OAuth token, otherwise you’ll get “Authorization has been denied.”

    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 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.