小编Eri*_*ric的帖子

如何以编程方式将应用程序添加到Azure AD?

我想在Azure AD中自动创建应用程序并获取Azure AD生成的客户端ID.

是否有PowerShell命令行开关来执行此操作?还有其他方法,比如管理控制台之外的API吗?

你能指点我一个例子吗?

谢谢!

powershell automation azure azure-active-directory

27
推荐指数
2
解决办法
2万
查看次数

403禁止使用Azure Graph API

尝试使用Graph API创建应用程序时,我从Azure AD获得403 Forbidden响应:

private static void CreateApplicationViaPost(string tenantId, string clientId, string clientSecret)
{
    var authContext = new AuthenticationContext(
        string.Format("https://login.windows.net/{0}",
        tenantId));

    ClientCredential clientCred = new ClientCredential(clientId, clientSecret);

    AuthenticationResult result = authContext.AcquireToken(
        "https://graph.windows.net",
        clientCred);

    HttpClient client = new HttpClient();
    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", result.AccessToken);

    const string json = @"{ displayName: ""My test app"", logoutUrl: ""http://logout.net"", identifierUris: [ ""http://identifier1.com"" ], replyUrls: [ ""http://replyUrl.net"" ] }";
    HttpResponseMessage response = client.PostAsync(
        string.Format("https://graph.windows.net/{0}/applications?api-version=1.6", tenantId),
        new StringContent(json, Encoding.UTF8, "application/json")).Result;

    Console.WriteLine(response.ToString());
}
Run Code Online (Sandbox Code Playgroud)

在Azure AD中注册的客户端具有以下所有权限: Azure AD中的权限

我错过了什么?

编辑: 我在Azure …

c# azure azure-active-directory azure-ad-graph-api

5
推荐指数
1
解决办法
6160
查看次数