带有 B2C AD 的 Azure Graph

Azure Graph with B2C AD

当我尝试使用

从我的 Azure AD B2C 应用获取令牌时

Microsoft.IdentityModel.Clients.ActiveDirectory - 3.13.1 Microsoft.Azure.ActiveDirectory.GraphClient - 2.1.0

像这样:

var authUri = "https://login.microsoftonline.com/6b7403d6-xxxx-xxxx-xxxx-xxxxxxxxxxxx/oauth2/token";
var clientId = "59e08b82-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
var appKey = "XXXX-MyAppKey-XXXX";
var graphUri = "https://graph.windows.net/6b7403d6-xxxx-xxxx-xxxx-xxxxxxxxxxxx";

var authenticationContext = new AuthenticationContext(authUri, false);
var clientCred = new ClientCredential(clientId, myAppKey);

var authenticationResult = await authenticationContext.AcquireTokenAsync(graphUri, clientCred);

我明白了

[AdalServiceException: AADSTS70001: Application '59e08b82-xxxx-xxxx-xxxx-xxxxxxxxxxxx' is not supported for this API version.

有没有我可以在 ASP.NET MVC 5 (.NET 4.5) 中使用的库来访问我使用 new Azure Portal, not PowerShell from this example 的 UI 创建的 B2C 活动目录?

(此处的 xxxx 仅用于保护隐私)

您引用的示例:https://azure.microsoft.com/en-us/documentation/articles/active-directory-b2c-devquickstarts-graph-dotnet/ 仅使用 powershell 设置服务主体。

获得服务主体后,您可以在代码中使用它来访问图表 API。该示例从控制台应用程序执行此操作,但这在 MVC 5

中也适用

您不再需要权力 shell 创建,MSFT 已授予在 Azure AD(不是 azure b2c)中添加新应用程序的权限,该应用程序可用于访问 Graph API 在天蓝色的 B2C 中。您需要按照以下步骤进行操作 IN https://docs.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-devquickstarts-graph-dotnet

仅用于删除图表的访问权限api您需要做一些强大的-shell魔法...