【发布时间】:2019-09-17 19:56:26
【问题描述】:
我找到了关于如何对动态进行身份验证的文档,但它是针对 xamarin 表单的,并且已经对其进行了测试。
但现在我想在不使用 xamarin 表单库的情况下在 xamarin Android 上正确地对动态进行身份验证
有没有一种方法可以对为 xamarin Android 制作的动态进行身份验证,而我不需要使用 xamarin 表单方式进行身份验证?
有关如何使用 xamarin 表单对动态进行身份验证的文档 https://www.c-sharpcorner.com/article/azure-active-directory-login-in-xamarin-forms/
我的身份验证器类:
[assembly: Xamarin.Forms.Dependency(typeof(Apontamento_Despesa.Authenticator))]
public class Authenticator : IAuthenticator
{
public async Task<AuthenticationResult> Authenticate(string authority, string resource, string clientId, string returnUri)
{
var authContext = new AuthenticationContext(authority);
if (authContext.TokenCache.ReadItems().Count() > 0)
authContext = new AuthenticationContext(authContext.TokenCache.ReadItems().First().Authority);
var uri = new Uri(returnUri);
var platformParams = new PlatformParameters((Activity)Forms.Context);
var authResult = await authContext.AcquireTokenAsync(resource, clientId, uri, platformParams);
return authResult;
}
}
【问题讨论】:
标签: c# xamarin.android microsoft-dynamics