使用全局管理员用户名和密码在Azure AD中创建应用程序的代码

问题描述 投票:0回答:1

我找到了通过Azure AD Graph API创建Azure AD应用程序的代码示例。

var application = new Application()
            {
                AvailableToOtherTenants = false,
                DisplayName = appname,
                ErrorUrl = null,
                GroupMembershipClaims = null,
                Homepage = string.Format("http://www.{0}.com", _azureDomain),
                IdentifierUris = new List<string>() { { string.Format("https://{0}/{1}",_azureDomain, appname )} },
                KeyCredentials = new List<KeyCredential>(),
                KnownClientApplications = new List<Guid>(),
                LogoutUrl = null,
                Oauth2AllowImplicitFlow = false,
                Oauth2AllowUrlPathMatching = false,
                Oauth2Permissions = new List<OAuth2Permission>();
            }          
await graphClient.Applications.AddApplicationAsync(application); 

但是我没有找到仅使用全局管理凭据的graphClient实例化示例,而没有为此目的手动创建其他应用程序。 Here in section 9 there is explanation of how this application has to be created. 这是对的吗?要使用全局管理凭据进行身份验证,需要创建应用程序吗? 如果我错了,这样的身份验证是可能的,有人可以添加代码示例吗?

azure office365 azure-active-directory azure-ad-graph-api
1个回答
1
投票

这有点像“鸡蛋和鸡蛋”的情景。

除非已注册调用应用程序,否则无法访问Graph API。

因此,您需要手动创建包含AAD租户中代码的应用程序,并授予其对租户的写入权限。

© www.soinside.com 2019 - 2024. All rights reserved.