我正在尝试使用Active Directory实现登录/登录功能。我基于这个b2c-xamarin sample。
以下是我遇到问题的相关代码。我在这里进行了修改以简化可读性。我已为任何noteworty插入注释,尤其是AcquireTokenAsync:
string ClientID = "<application_id_of_b2c_application>"
string Authority = "https://login.microsoftonline.com/tfp/<b2c_tenant_name>/<signin_policy_name>/oauth2/v2.0/authorize"
PublicClientApplication PCA = new PublicClientApplication(ClientID, Authority);
// The application says to override this which I do not as I am not sure if its required for actual sign in
PCA.RedirectUri = $"msal{ClientID}://auth";
// UWP SIGN IN CODE
string Scopes = { "User.Read" };
string PolicySignUpSignIn = "<signin_policy_name>";
// Arguments #2 and #3 both return null. This happens also with the unmodified sample that works.
// I do not know what to put in for argument #1 (scopes) - I have tried numerous combinations to no avail. currently I have { "User.Read" }
AuthenticationResult ar = await PCA.AcquireTokenAsync(Scopes, GetUserByPolicy(PCA.Users, PolicySignUpSignIn), PCA.UiParent);
调用AcquireTokenAsync时获得的重复是以下内容(为了便于阅读而截断 - 我插入了开头和结尾)
{Microsoft.Identity.Client.MsalException:WAB身份验证失败 ---&GT; System.IO.FileNotFoundException:指定的协议未知。 (来自HRESULT的异常:0x800C000D)at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务 任务)......(TRUNCATION)...... ---从抛出异常的先前位置开始的堆栈跟踪结束--- at UserDetailsClient.MainPage.d__2.MoveNext() ErrorCode:authentication_ui_failed}
我认为问题的方法可能是以下任何一种:
我已根据Azure AD中的值尝试了许多参数组合,但无济于事。我真的可以使用一些帮助。