问题
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:
- Get a token from https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token
- 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:
- In Azure Portal -> App registrations -> API permissions add the Microsoft Graph application permission
Organization.Read.All
- For each tenant, ask the Microsoft Teams admin to visit: https://login.microsoftonline.com/${tenantId}/adminconsent
- Get a graph token for the tenant via https://login.microsoftonline.com/${tenantId}/oauth2/v2.0/token (scope: graph.microsoft.com/.default)
- 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