How to get the organization/company name in bot and message extension

Brass Contributor

Hi,

 

I am using the bot framework to create the bot and message extensions. I would like to know how to get the organization/company name in bot and extension. In the bot payload(context), I can see the tenantId but couldn't see the organization details. How can I get it?

 

I tried using the microsoft-graph-client node js module but getting the following error

 [onTurnError] unhandled error: Error: The identity of the calling application could not be established.

These are the code

import "isomorphic-fetch";
            import "@babel/polyfill";
            import { Client } from "@microsoft/microsoft-graph-client";

            const { ClientSecretCredential, ChainedTokenCredential } = require("@azure/identity");
            import { TokenCredentialAuthenticationProvider, TokenCredentialAuthenticationProviderOptions } from "@microsoft/microsoft-graph-client/authProviders/azureTokenCredentials";

            const credential = new ClientSecretCredential(<tenantId>, <clientId>, <clientSecret>);

            const authProvider = new TokenCredentialAuthenticationProvider(credential, { scopes: ['https://graph.microsoft.com/.default'] });
            const client = Client.initWithMiddleware({
                debugLogging: true,
                authProvider,
            });

            const res = await client.api("/organization").get();
1 Reply

@fabin10 

There are two common reasons that cause this particular error:
The first being the Azure AD application is not figured to be available to any organization. You can confirm the Azure AD application is configured correctly by checking the supported account type configuration found in the authentication section.

The second reason you might encounter this error is due to the Azure AD consent framework.

And as you mentioned ,In the bot payload(context), you will get tenant Id but won't the organization details. You can refer this link to get Org details using MS Graph API.