Search code examples
restbotframeworkmicrosoft-graph-apiazure-bot-servicemicrosoft-graph-teams

Adding MS Graph API Oauth in Azure Bot Services using REST API


I am using REST API for Azure Bot Services and GRAPH API for creating MS Teams Bot.

I have been using two different oauths for my application since I require my bot to get details from GRAPH API.

https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token - for bot services https://login.microsoftonline.com/common/oauth2/v2.0/token - for graph api

Is there a way to combine them, and use single ouath for both the purpsoses? I went through the documentaion and there is a way where bot can ask for graph api authentication from user.

I saw many examples for SDKs but I am not able to figure out how to do this in REST API.

I have followed this documnetation uptil here.

Can anyone please let me know if I am doing it right and further steps to be taken to add MS Graph API Oauth in Bot itself?


Solution

  • No. There is no way to combine them. We can only use a one token for one purpose.

    The document you provided is to tell that we can use a bot to call Microsoft Graph. See reference here: Add authentication to a bot.

    Creating the bot and use the bot to call Microsoft Graph should be should be two separate processes.

    After creating the bot, you need to configure the AAD authentication to it, then you could use it to call Microsoft Graph.

    See the Bot Graph sample.