Xamarin.Forms& Adal身份验证4 AcquireTokenAsync

时间:2016-05-24 09:38:05

标签: c# xamarin xamarin.forms adal

我在Xamarin.Forms便携式Adal 4实验(Microsoft.Experimental.IdentityModel.CLients.ActiveDirectory)中对用户进行身份验证时遇到问题。我找不到如何使用AcquireTokenAsync,因为文档仅适用于以前版本的adal,AcquireTokenAsync现在不同了。有人可以在这里提供一个有效的例子吗?

1 个答案:

答案 0 :(得分:0)

还有一些额外的参数,是的,但它们只是设置。如果您的应用程序已在Azure AD中注册:

AuthenticationParameters ap = AuthenticationParameters.CreateFromResourceUrlAsync(new Uri(resource+"/api/data/v8.1")).Result;

IPlatformParameters parameters = new PlatformParameters(PromptBehavior.Auto);

AuthenticationResult r = await ac.AcquireTokenAsync(ap.Resource, clientId, new Uri(redirectUrl), parameters);

如果您知道将要登录的人员的详细信息,您可以使用:

AuthenticationResult r = await ac.AcquireTokenAsync(ap.Resource, clientId, new Uri(redirectUrl), parameters, new UserIdentifier(username,UserIdentifierType.RequiredDisplayableId));