如何从graph.microsoft.com获取Azure租户名称? [英] How to get Azure tenant name from graph.microsoft.com?
问题描述
我需要发现用户的租户名称,因为将要使用Azure服务的服务终结点resourceId要求我指定租户名称:
I need to discover user's tenant name, since the service endpoint, resourceId that I'll be using an Azure service that requires me to specify the tenant name:
服务端点: https://[tenantnamme] .api.crm.dynamics.com/ ...
资源ID: https://[tenantname] .crm.dynamics.com
service endpoint: https://[tenantnamme].api.crm.dynamics.com/...
resource Id: https://[tenantname].crm.dynamics.com
我希望Unified Microsoft Graph API可以为我发现这一点.我看了看文档,可以看到最接近的文档 graph.microsoft.com/v1.0/organization 这会给我回馈: verifyDomains:[ .... 名称":"contoso.onmicrosoft.com" ]
I was hoping Unified Microsoft Graph API can discover this for me. I looked at the documentation, the closest I can see is to use graph.microsoft.com/v1.0/organization which will give me back: verifiedDomains : [ .... "name" : "contoso.onmicrosoft.com" ]
但是,我不确定这是否是正确的方法.如果组织有多个经过验证的域怎么办?验证后的域名是否与租户名称相同?
But, I'm not sure if this is the right approach. What if an org has multiple verified domains? Does verified domain name is the same as tenant name?
更新:这是我的真实情况.我有一个Web应用程序,允许用户通过OAuth2向Azure AD进行身份验证.我从OAuth交互中获取刷新令牌和访问令牌没有问题.但是,在其他使用其他服务时,则需要在其服务端点中使用[azure-ad-tenant-name].那是我的问题.
Update: This is my real scenario. I have a web app that allows user to authenticate to Azure AD via OAuth2. I have no problem obtaining refresh token and access token from OAuth interactions. However, in other to use other service, it requires [azure-ad-tenant-name] in their service end point. That's my question coming from.
推荐答案
我相信您在 graph.microsoft.com/v1.0/organization 端点上走的正确.您应该可以在 verifiedDomains 列表中找到租户名称.应当包含带有租户名称的域的条目是初始域:
I believe that you're on the right track with the graph.microsoft.com/v1.0/organization endpoint. You should be able to find the tenant name in the verifiedDomains list. The entry that should contain domain with the tenant name is the initial domain:
{
...
"isInitial": true,
"name": "contoso.onmicrosoft.com",
...
}
这篇关于如何从graph.microsoft.com获取Azure租户名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!