【发布时间】:2018-01-03 11:05:11
【问题描述】:
我正在使用以下代码对我的 Azure 试用帐户中的默认用户进行身份验证。
static void Main(string[] args)
{
GetTokenAsync().Wait();
}
static async Task<string> GetTokenAsync()
{
string Tenant = "mytest.onmicrosoft.com";
string Authority = "https://login.microsoftonline.com/" + Tenant;
string GatewayLoginUrl = "https://login.microsoftonline.com/something/wsfed";
string ClientId = "something";
Uri RedirectUri = new Uri("http://something");
AuthenticationContext context = new AuthenticationContext(Authority);
PlatformParameters platformParams = new PlatformParameters(PromptBehavior.Auto, null);
AuthenticationResult result = await context.AcquireTokenAsync(GatewayLoginUrl, ClientId, RedirectUri, platformParams);
return result.ToString();
}
我想知道从哪里获取这些值:
- 租户
- 权威
- 网关登录网址
- 客户标识
- RedirectUri
这么多代码是否足以使用 AD 进行用户身份验证?
【问题讨论】:
-
这取决于您的type of application and scenario。根据您的应用类型,查看其中一个示例 here
-
@PeterBons 到目前为止,我已经注册了一个原生应用程序。为此如何获取 GatewayAccessURL 和 Redirect?
-
对于重定向,您可以使用 localhost 例如,因为本机应用程序不需要重定向 url。 GatewayLoginUrl 是您可以在客户端应用程序的属性中找到的应用程序 id uri
-
@PeterBons 你能提交这个作为答案吗?带有 GatewayLoginUrl 的截图。
标签: azure azure-active-directory