![](/img/trans.png)
[英]Azure Active Directory Verify Access Token in Web Api outside of Azure
[英]How to configure Web Api access as Azure Active Directory Graph API
我已经安装了WebApi应用程序,并且在权限下它可以访问Windows Azure Active Directory。
该应用程序能够访问图形api,并且没有提示用户登录。
如何为WebApi实现类似的设置? 我只希望具有权限设置的应用程序可以访问它。 我是这样设置的: http : //bitoftech.net/2014/09/12/secure-asp-net-web-api-2-azure-active-directory-owin-middleware-adal/
但是与访问“ Windows Azure Active Directory”的图形API时不同,它会提示您进行登录。
如果不想提示您进行身份验证,则需要使用AcquireTokenAsync的其他重载。 从本质上讲,这意味着使用密码进行应用程序身份验证。
string tenantId = "[your domain, such as contoso.onmicrosoft.com]";
string clientSecret = "[Get this from the CONFIGURE page in the portal]";
string resAzureGraphAPI = "https://graph.windows.net";
var context = new AuthenticationContext(string.Format("https://login.windows.net/{0}", tenantId));
ClientCredential clientCred = new ClientCredential(clientId, clientSecret);
AuthenticationResult result = await context.AcquireTokenAsync(resAzureGraphAPI, clientCred);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.