【问题标题】:Xamarin.Forms & Adal Authentication 4 AcquireTokenAsyncXamarin.Forms 和 Adal 身份验证 4 AcquireTokenAsync
【发布时间】:2016-09-21 10:35:12
【问题描述】:

我在使用 Adal 4 实验性 (Microsoft.Experimental.IdentityModel.CLients.ActiveDirectory) 验证 Xamarin.Forms Portable 中的用户时遇到问题。我找不到如何使用AcquireTokenAsync,因为文档仅适用于以前版本的adal,而AcquireTokenAsync 现在不同了。有人可以在这里提供一个工作示例吗?

【问题讨论】:

    标签: c# xamarin xamarin.forms adal


    【解决方案1】:

    有一些额外的参数,是的,但它们只是设置。如果您的应用程序已在 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));
    

    【讨论】:

    • 感谢您的回答。 Adal 现在被 msal 取代,可以在 github 上找到一些 msal 的示例。不幸的是,我无法检查您的解决方案,因为我使用了其他东西。
    • 它没有被替换,它的用途与 ADAL 略有不同。 Microsoft 不会为 MSAL 搁置 ADAL。现在,MSAL 似乎是您想与 Xamarin 一起使用的库。
    猜你喜欢
    • 2020-02-11
    • 1970-01-01
    • 1970-01-01
    • 2018-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多