Mobile 将用户凭据传递给Adal AquireTokenAsync

Mobile 将用户凭据传递给Adal AquireTokenAsync,mobile,active-directory,passwords,credentials,adal,Mobile,Active Directory,Passwords,Credentials,Adal,我正在使用Adal(Active Directory身份验证库)版本3.13.x。我正在执行下面的操作来获取访问令牌 AuthResult = await AuthContext.AcquireTokenAsync(relyingUrl, ServiceConstants.CLIENTID, ServiceConstants.RETURNURI, param); 我还需要传递UserCredentials,但是现在我只能向UserCredential()传递一个参数,这与Adal的2.x.x版

我正在使用Adal(Active Directory身份验证库)版本3.13.x。我正在执行下面的操作来获取访问令牌

AuthResult = await AuthContext.AcquireTokenAsync(relyingUrl, ServiceConstants.CLIENTID, ServiceConstants.RETURNURI, param);
我还需要传递UserCredentials,但是现在我只能向UserCredential()传递一个参数,这与Adal的2.x.x版本不同

我还尝试使用解决方案中建议的
UserPasswordCredential
,但由于我想从移动应用程序获取令牌,因此我只能访问.net Core,因此无法使用
UserPasswordCredential

我想在获取令牌时同时传递用户名和密码。我有什么办法可以做到这一点吗

任何帮助都将不胜感激

编辑 在尝试了FeiXue-MSFT的解决方案后,我得到了以下503错误

我想在获取令牌时同时传递用户名和密码。我有什么办法可以做到这一点吗

在这个场景中,我们可以直接执行REST请求,而不是使用客户端库。以下是一个样本供您参考:

Post:https://login.microsoftonline.com/{tenant}/oauth2/token

resource={resource}&client_id={clientId}&grant_type=password&username={userName}&password={password}
更新
谢谢你的回复。知道我如何在授权为AD FS的情况下做到这一点吗?不熟悉AD FS,但是您可以尝试使用库使用此流获取令牌,并通过Fiddler捕获请求以获取详细信息。请检查我的编辑。我对此很陌生,因此出现了一些问题。如果您使用Adal库发送请求,请求是否成功?我还没有尝试使用Adal的这种方法。你能告诉我怎么做吗?
string authority = "https://login.microsoftonline.com/{tenantid}";
string resrouce = "https://graph.windows.net";

string clientId = "";
string userName = "";
string password = "";
UserPasswordCredential userPasswordCredential = new UserPasswordCredential(userName, password);
AuthenticationContext authContext = new AuthenticationContext(authority);
var token = authContext.AcquireTokenAsync(resrouce, clientId, userPasswordCredential).Result.AccessToken;

Console.WriteLine(token);