简体   繁体   English

带有 B2C AD 的 Azure Graph

[英]Azure Graph with B2C AD

When I try to acquire a token from my Azure AD B2C app using当我尝试使用 Azure AD B2C 应用程序获取令牌时

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

like this:像这样:

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);

I get我得到

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

Is there a library I can use in ASP.NET MVC 5 (.NET 4.5) to get access to the B2C Active directory I created using the UI of the new Azure Portal , not PowerShell from this example ?是否有我可以在 ASP.NET MVC 5 (.NET 4.5) 中使用的库来访问我使用新 Azure 门户的 UI 创建的 B2C 活动目录,而不是本示例中的PowerShell?

(The xxxx's are just for privacy here) (这里的 xxxx 只是为了隐私)

You don't need power shell creation any more, MSFT have given permission to add a new application in Azure AD(not in azure b2c), which can be used to access Graph API in azure B2C.您不再需要创建 power shell,MSFT 已授予在 Azure AD 中添加新应用程序(不在 azure b2c 中)的权限,该应用程序可用于访问 azure B2C 中的 Graph API。 You need to follow below steps IN https://docs.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-devquickstarts-graph-dotnet您需要按照以下步骤在https://docs.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-devquickstarts-graph-dotnet

Only for Deleting access for your graph api you need to do some power-shell magic...仅为了删除对图形 api 的访问,您需要执行一些 power-shell 魔术...

The example you referenced: https://azure.microsoft.com/en-us/documentation/articles/active-directory-b2c-devquickstarts-graph-dotnet/ only uses powershell to set up a Service Principal.您引用的示例: https : //azure.microsoft.com/en-us/documentation/articles/active-directory-b2c-devquickstarts-graph-dotnet/仅使用 powershell 来设置服务主体。

After you have the Service Principal, you can use that in your code to access the Graph API.拥有 Service Principal 后,您可以在代码中使用它来访问 Graph API。 The example does this from a console app, but this works as well from MVC 5该示例从控制台应用程序执行此操作,但这也适用于 MVC 5

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM