public boolean onAuthFailure ( AuthFailure failure ) { if ( failure . type == OAuthWebView . AuthFailure . TYPE_WEB_ERROR ) { if ( failure . mWebException . getErrorCode ( ) == WebViewClient . ERROR_CONNECT || failure . mWebException . getErrorCode ( ) == WebViewClient . ERROR_HOST_LOOKUP || failure . mWebException . getErrorCode ( ) == WebViewClient . ERROR_TIMEOUT ) { return false ; } Resources resources = this . getResources ( ) ; Toast . makeText ( this , String . format ( "%s\n%s: %s" , resources . getString ( com . box . sdk . android . R . string . boxsdk_Authentication_fail ) , resources . getString ( com . box . sdk . android . R . string . boxsdk_details ) , failure . mWebException . getErrorCode ( ) + " " + failure . mWebException . getDescription ( ) ) , Toast . LENGTH_LONG ) . show ( ) ; } else if ( SdkUtils . isEmptyString ( failure . message ) ) { Toast . makeText ( this , R . string . boxsdk_Authentication_fail , Toast . LENGTH_LONG ) . show ( ) ; } else { switch ( failure . type ) { case OAuthWebView . AuthFailure . TYPE_URL_MISMATCH : Resources resources = this . getResources ( ) ; Toast . makeText ( this , String . format ( "%s\n%s: %s" , resources . getString ( com . box . sdk . android . R . string . boxsdk_Authentication_fail ) , resources . getString ( com . box . sdk . android . R . string . boxsdk_details ) , resources . getString ( com . box . sdk . android . R . string . boxsdk_Authentication_fail_url_mismatch ) ) , Toast . LENGTH_LONG ) . show ( ) ; break ; case OAuthWebView . AuthFailure . TYPE_AUTHENTICATION_UNAUTHORIZED : AlertDialog loginAlert = new AlertDialog . Builder ( this ) . setTitle ( com . box . sdk . android . R . string . boxsdk_Authentication_fail ) . setMessage ( com . box . sdk . android . R . string . boxsdk_Authentication_fail_forbidden ) . setPositiveButton ( com . box . sdk . android . R . string . boxsdk_button_ok , new DialogInterface . OnClickListener ( ) { @ Override public void onClick ( final DialogInterface dialog , final int whichButton ) { dialog . dismiss ( ) ; finish ( ) ; } } ) . create ( ) ; loginAlert . show ( ) ; return true ; default : Toast . makeText ( this , com . box . sdk . android . R . string . boxsdk_Authentication_fail , Toast . LENGTH_LONG ) . show ( ) ; } } finish ( ) ; return true ; }
Callback method to be called when authentication failed .