2

当我尝试使用 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) 中使用的库来访问我使用新 Azure 门户的 UI 创建的 B2C 活动目录,而不是本示例中的 PowerShell ?

(这里的 xxxx 只是为了保护隐私)

4

2 回答 2

1

您不再需要创建 power shell,MSFT 已允许在 Azure AD 中添加一个新应用程序(不在 azure b2c 中),该应用程序可用于在 azure B2C 中访问 Graph API。您需要按照以下步骤在https://docs.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-devquickstarts-graph-dotnet

仅对于删除您的图形 api 的访问权限,您需要做一些 power-shell 魔术......

于 2017-07-27T04:37:02.807 回答
0

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

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

于 2016-08-09T08:04:43.230 回答