2014-10-24 2 views
0

Windows Phone 8.0 프로젝트 용 Auth0Client를 사용하고 있습니다. Auth0.SDK.AuthenticationCancelException 문제가 있습니다. LoginFacebookTap 버튼을 클릭 한 직후에 버튼을 누르면 항상 내 응용 프로그램이 충돌합니다. 나는 응용 프로그램을로드 할 때Windows Phone 8.0 프로젝트의 Auth0.SDK.AuthenticationCancelException

그래서 내가 LoginView 페이지로 이동하여 호출 버튼이 있습니다 :

private async void LoginFacebookTap(object sender, System.Windows.Input.GestureEventArgs e) 
{ 
    var result = await authorizationService.LoginAuth0(AuthorizationService.AuthorizationServiceType.Facebook, "", ""); 
    if (result == true) 
    { 
     MessageBox.Show("OK!"); 
    } 
} 

가이 그것을 내 방법 LoginAuth0

public async Task<Boolean> LoginAuth0(AuthorizationServiceType type, string email, string password) 
{ 
    if (NetworkService.IsNetworkAvailable()) 
    { 
     try 
     { 
      Auth0User user; 
      switch (type) 
      { 
       case AuthorizationServiceType.EmailAndPassword: 
        user = await auth0.LoginAsync(Constants.login_with_password_Auth0, email, password); 
        break; 
       case AuthorizationServiceType.Email: 
        user = await auth0.LoginAsync(Constants.login_azure_Auth0); 
        break; 
       case AuthorizationServiceType.Facebook: 
        user = await auth0.LoginAsync(Constants.login_facebook_Auth0); 
        break; 
       case AuthorizationServiceType.Google: 
        user = await auth0.LoginAsync(Constants.login_google_Auth0); 
        break; 
       case AuthorizationServiceType.Linkedin: 
        user = await auth0.LoginAsync(Constants.login_linkedin_Auth0); 
        break; 
       case AuthorizationServiceType.Twitter: 
        user = await auth0.LoginAsync(Constants.login_twitter_Auth0); 
        break; 
       case AuthorizationServiceType.Windows: 
        user = await auth0.LoginAsync(Constants.login_windows_Auth0); 
        break; 
      } 
     } 
     catch (AuthenticationCancelException) 
     { 
      System.Diagnostics.Debug.WriteLine("User press cancel on Authentication"); 
      return false; 
     } 
     catch (AuthenticationErrorException ex) 
     { 
      MessageBox.Show(Resources.AppResources.TitleError + " : " + ex.Message); 
      return false; 
     } 
     catch (Exception exc) 
     { 
      MessageBox.Show(Resources.AppResources.MessageErrorUserNotExists); 
      System.Diagnostics.Debug.WriteLine("Unknown exception: "+exc.Message); 
      return false; 
     } 

     try 
     { 
      var targetClientId = Constants.clientId_Auth0; 
      var options = new Dictionary<string, string> 
      { 
       { "scope", "openid profile" } 
      }; 
      var delegationResult = await auth0.GetDelegationToken(targetClientId, options); 

      if (delegationResult != null) 
      { 
       String jsonString = delegationResult["id_token"].ToString(); 
       System.Diagnostics.Debug.WriteLine("Application received token: " + jsonString); 
       return true; 
      } 
      else MessageBox.Show(AppResources.MessageErrorSigning); 
     } 
     catch(Exception exc) 
     { 
      MessageBox.Show(Resources.AppResources.TitleError +" : " + exc.Message); 
     } 
     return false; 
    } 
    else 
    { 
     MessageBox.Show(Resources.AppResources.MessageErrorNoConnection); 
     return false; 
    } 
} 

그냥 내가 LoginFacebookTap을 클릭 후 뒤로 버튼을 누르면 결과는

의 첫 번째 예외입니다210 'Auth0.SDK.AuthenticationCancelException'이 (가) 에서 발생했습니다. Auth0Client.Phone.Silverlight.ni.DLL 의 첫 번째 예외가 적용됩니다. mscorlib.ni.dll에서 'Auth0.SDK.AuthenticationCancelException'이 발생했습니다. 첫 번째 예외는 ' Auth0.SDK.AuthenticationCancelException는 InvalidOperationException이 없습니다 "와 충돌 System.InvalidOperationException ' 이 Microsoft.Phone.ni.dll

다음 응용 프로그램을 발생'mscorlib.ni.dll 유형의 첫 번째 예외 발생 ' CanGoBack이 거짓 일 때 돌아 가라. " 벌레 야?

업데이트

내가 파악하는 것은 당신이 당신의 페이스 북 계정에 로그인 할 때만 발생하고 인증하는 것입니다. 그런 다음 다시 애플리케이션을 실행하고 LoginFacebookTap을 클릭하면 페이스 북 로그인 페이지로 리디렉션되지 않지만 인증 결과가 'OK'인 경우 자동으로 리디렉션됩니다. LoginView로 리디렉션되기 전에 흰색 화면이 나타나고 Back을 누르면 "InvalidOperationException CanGoBack이 false 일 때 돌아갈 수 없습니다."와 함께 반환됩니다.

업데이트 내가 Auth0.SDK에 알아낼 무엇 2

:

NavigationService.GoBack에서
/// <summary> 
/// Handler for the browser control's navigation failed event. We use this to detect errors 
/// </summary> 
private void BrowserControl_NavigationFailed(object sender, NavigationFailedEventArgs e) 
{ 
    WebBrowserNavigationException navEx = e.Exception as WebBrowserNavigationException; 

    if (navEx != null) 
    { 
     // Pass along the provided error information. 
     responseErrorDetail = string.Format("Error code: {0}", navEx.StatusCode); 
    } 
    else 
    { 
     // No error information available. 
     responseErrorDetail = NoDetailsAvailableMessage; 
    } 
    responseStatus = PhoneAuthenticationStatus.ErrorHttp; 

    authenticationFinished = true; 
    e.Handled = true; 

    // Navigate back now. 
    this.NavigateBackWithProgress(); 
} 

/// <summary> 
/// Displays the progress bar and navigates to the previous page. 
/// </summary> 
private void NavigateBackWithProgress() 
{ 
    ShowProgressBar(); 
    NavigationService.GoBack(); 
} 

(); InvalidOperationException CanGoBack이 false 인 경우 되돌릴 수 없습니다.

+0

그래서 try/catch가 작동하지 않는다고 말씀 하시겠습니까? – woloski

+0

아니, 어디서 왔는지 모르겠다. – boski

답변

0

그것은 SDK에 버그 확인, 그래서 당신은 그것을 잡는됩니다

private void NavigateBackWithProgress() 
{ 
    ShowProgressBar(); 
    if(NavigationService.CanGoBack) 
     NavigationService.GoBack(); 
} 

NavigationService.GoBack를 호출하기 전에 백 스택에 짝수 페이지가있는 경우() 우리가 항상 확인해야합니다. 또한 참조 :

private void NavigateBackWithProgress() 
{ 
    ShowProgressBar(); 
    if(this.Frame != null && this.Frame.CanGoBack) 
     this.Frame.GoBack(); 
} 
0

예, 인증을 취소하면 SDK가 예외를 throw합니다. 그

+0

아닙니다. SDK를 throw하는 예외는 아니지만 NavigationService.GoBack()을 호출하기 전에 백 스택에 짝수 페이지가 있는지 항상 확인해야하기 때문에 예외입니다. SDK를 복제하고 if (NavigationService.CanGoBack) 확인을 추가합니다. – boski

관련 문제