0
ADAL을 사용하여 사용자를 인증하는 앱이 있습니다. 로그인 버튼을 누르면 로그인 페이지가 나타나지만 올바른 자격 증명을 입력 한 후에는 아무 것도 발생하지 않습니다. 인증에 필요한 모든 변수 (일반 권한, URI, 클라이언트 ID 리디렉션)를 확인한 후에도 여전히 나타납니다.Azure Active Directory에서 로그인 성공 후 인증을 통과하지 못합니다.
인증 부분은 다음과 같습니다.
private async Task<bool> AuthenticateUsingADAL(IPlatformParameters parent)
{
var success = false;
try
{
AuthenticationContext authContext = new AuthenticationContext(CommonAuthority);
if (authContext.TokenCache.ReadItems().Count() > 0)
authContext = new AuthenticationContext(authContext.TokenCache.ReadItems().First().Authority);
AuthResult = await authContext.AcquireTokenAsync(ResourceUri, ClientId, RedirectUri, parent);
//i put a WriteLine here but nothing goes through after the AuthResult. I don't know why
success = true;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("Authentication failed " + ex.ToString());
}
return success;
}
로그인 활동
public bool Login(Activity activity)
{
bool result = false;
if (String.IsNullOrEmpty(Token) || TokenExpired) result = AuthenticateUsingADAL(new PlatformParameters(activity)).Result;
return result;
}
이에 의해 시작됩니다 : 당신은 캐시에서 일을 읽으려는
private void BtnLogin_Click(object sender, EventArgs e)
{
bool success = false;
Task loginTask = new Task(() =>
{
success = SessionsHelper.Login(this);
});
loginTask.ContinueWith(t =>
{
if (success) GoToNextActivity();
}, TaskScheduler.FromCurrentSynchronizationContext());
loginTask.Start();
}