I have registered an application in the Azure portal by selecting the option 'Accounts in any organizational directory (Any Microsoft Entra ID tenant - Multitenant)'. Also added an external tenant user.
When I tried to use the app's client ID, tenant ID, and secret key with the external user's login, I got redirected to the call-back method and was able to generate an access token based on the app's client ID, tenant ID, and secret key with the authorized code (which I got from callback).
When I tried to get the company details using the access token with the app's tenant ID, I got an unauthorized error in Postman.
Is the above flow correct or not?
Using the app's tenant ID to generate an access token is valid or not and how to get the external user's tenant ID or how to generate an access token for the external tenant?
Also how to get the environment name for the tenant user and company details?
Because in APIs, I have to add the environment name, tenant ID, and company ID.
Which tenant_id do I have to use and if it is for an external user then how to get it?
How to get the environment name for the external tenant user?
How to get company details for an external tenant user?
***Note***
For the same tenant, I used the app's tenant ID and was able to get company_ID from the API response and also able to get Sales orders. The environment name I got from the Admin Center from Dynamics 365 Business Central. But for trial users where should I get this?
How to connect the external tenant user to connect with Azure portal app using the portal user's client ID, and client secret?
API:
https:/api.businesscentral.dynamics.com/v2.0/{{tenant_Id}}/Production/api/v2.0/companies({{company_Id}})/salesOrders