Azure图与B2C广告

本文关键字:广告 B2C 图与 Azure | 更新日期: 2023-09-27 18:01:16

当我尝试使用

从Azure AD B2C应用程序获取令牌时

Microsoft.IdentityModel.Clients.ActiveDirectory - 3.13.1Microsoft.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)来访问我使用新Azure Portal的UI创建的B2C活动目录,而不是本例中的PowerShell ?

(这里xxxx只是为了隐私)

Azure图与B2C广告

你不再需要创建power shell了,MSFT已经允许在Azure AD中添加一个新的应用程序(而不是在Azure b2c中),它可以用来访问Azure b2c中的Graph API。您需要在https://learn.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-devquickstarts-graph-dotnet

中执行以下步骤

仅用于删除您的图形api的访问权限,您需要做一些power-shell魔法…

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

在你有了服务主体之后,你可以在你的代码中使用它来访问Graph API。这个例子是在控制台应用程序中完成的,但这在MVC 5
中也可以工作。