Forum Discussion
How to get access token for Graph API in Teams bot-based message extension?
Hi XDeveloper29 - Thanks for raising the query.
We will look into it and let you know the updates.
Update: Your questions about implementing OAuth and accessing the Graph API in your Teams bot-based message extension. To address your queries:
-
Implementing OAuth: You can implement OAuth in a bot-based message extension by sending an OAuth Card to the Teams client, which is used to get the access token from Microsoft Entra ID using
tokenExchangeResource
. Upon the user's consent, the Teams client sends the token received from Microsoft Entra ID to the bot app using token exchange. -
Permissions and Configurations: Specific permissions are required in the Azure portal to enable access to the Graph API. You must register your app and ask for specific permission scopes to obtain the access tokens upon the app user's consent.
-
Alternative Methods: If you're looking for an alternative way to retrieve the replies without using the Graph API, currently, the Graph API is the primary method provided by Microsoft to interact with Teams data programmatically.
For a detailed guide on implementing authentication and obtaining access tokens, please refer to the official Microsoft documentation:
- Enable SSO with Microsoft Entra ID - Teams | Microsoft Learn
- Microsoft Graph Permissions for App - Teams | Microsoft Learn
If you need any further assistance or have additional questions, please feel free to ask.