|
31 | 31 | import com.microsoft.aad.adal.AuthenticationCallback; |
32 | 32 | import com.microsoft.aad.adal.AuthenticationCancelError; |
33 | 33 | import com.microsoft.aad.adal.AuthenticationContext; |
| 34 | +import com.microsoft.aad.adal.AuthenticationException; |
34 | 35 | import com.microsoft.aad.adal.AuthenticationResult; |
35 | 36 | import com.microsoft.aad.adal.PromptBehavior; |
36 | 37 | import com.onedrive.sdk.core.ClientException; |
@@ -394,7 +395,13 @@ public void onSuccess(final AuthenticationResult authenticationResult) { |
394 | 395 |
|
395 | 396 | @Override |
396 | 397 | public void onError(final Exception e) { |
397 | | - error.set(new ClientAuthenticatorException("Silent authentication failure from ADAL", |
| 398 | + String message = "Silent authentication failure from ADAL"; |
| 399 | + if (e instanceof AuthenticationException) { |
| 400 | + message = String.format("%s; Code %s", |
| 401 | + message, |
| 402 | + ((AuthenticationException)e).getCode().getDescription()); |
| 403 | + } |
| 404 | + error.set(new ClientAuthenticatorException(message, |
398 | 405 | e, |
399 | 406 | OneDriveErrorCodes.AuthenticationFailure)); |
400 | 407 | loginSilentWaiter.signal(); |
@@ -509,7 +516,13 @@ public void onError(final Exception ex) { |
509 | 516 | code = OneDriveErrorCodes.AuthenticationCancelled; |
510 | 517 | } |
511 | 518 |
|
512 | | - final String message = "Error while retrieving the discovery service auth token"; |
| 519 | + String message = "Error while retrieving the discovery service auth token"; |
| 520 | + if (ex instanceof AuthenticationException) { |
| 521 | + message = String.format("%s; Code %s", |
| 522 | + message, |
| 523 | + ((AuthenticationException)ex).getCode().getDescription()); |
| 524 | + } |
| 525 | + |
513 | 526 | error.set(new ClientAuthenticatorException(message, ex, code)); |
514 | 527 | mLogger.logError("Error while attempting to login interactively", error.get()); |
515 | 528 | discoveryCallbackWaiter.signal(); |
@@ -609,12 +622,18 @@ public void onSuccess(final AuthenticationResult authenticationResult) { |
609 | 622 |
|
610 | 623 | @Override |
611 | 624 | public void onError(final Exception e) { |
| 625 | + String message = "Error while retrieving the service specific auth token"; |
612 | 626 | OneDriveErrorCodes code = OneDriveErrorCodes.AuthenticationFailure; |
613 | 627 | if (e instanceof AuthenticationCancelError) { |
614 | 628 | code = OneDriveErrorCodes.AuthenticationCancelled; |
615 | 629 | } |
| 630 | + if (e instanceof AuthenticationException) { |
| 631 | + message = String.format("%s; Code %s", |
| 632 | + message, |
| 633 | + ((AuthenticationException)e).getCode().getDescription()); |
| 634 | + } |
616 | 635 |
|
617 | | - error.set(new ClientAuthenticatorException("Error while retrieving the service specific auth token", |
| 636 | + error.set(new ClientAuthenticatorException(message, |
618 | 637 | e, |
619 | 638 | code)); |
620 | 639 | mLogger.logError("Unable to refresh token into OneDrive service access token", error.get()); |
|
0 commit comments