How to get the tenant name when integrating with Microsoft Teams

半腔热情 提交于 2020-07-10 10:27:10

问题


I have created a Microsoft Teams bot that can create/update conversations and receives all kinds of events to an endpoint (user joined team, ...). All I see in the events is a tenant id. For teams, i get an id and sometimes a name which is great.

to create/update conversations I use this flow:

  1. Get a token from https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token
  2. POST to a channel: ${serviceUrl}v3/conversations/${conversationId}/activities

My question is, how can I get the name of a tenant? I can not find any API to do so?

Use case: A user sends me a support email. I have no way to check my database and find the correct entries because all I know is the tenant id.

I have looked into the Graph API but I'm not sure if my bot is actually able to make those calls (I get all kinds of strange permissions errors such as Authorization_IdentityNotFound The identity of the calling application could not be established.).

I want to make the calls to the API myself. I don't want to use any Microsoft SDK/Lib/...


回答1:


It looks like I have to:

  1. In Azure Portal -> App registrations -> API permissions add the Microsoft Graph application permission Organization.Read.All
  2. For each tenant, ask the Microsoft Teams admin to visit: https://login.microsoftonline.com/${tenantId}/adminconsent
  3. Get a graph token for the tenant via https://login.microsoftonline.com/${tenantId}/oauth2/v2.0/token (scope: graph.microsoft.com/.default)
  4. Call the graph api https://graph.microsoft.com/v1.0/organization


来源:https://stackoverflow.com/questions/62659556/how-to-get-the-tenant-name-when-integrating-with-microsoft-teams

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!