Skip to content
This repository was archived by the owner on Oct 2, 2024. It is now read-only.

Commit 7585860

Browse files
author
Peter Nied
committed
Adding the ADAL error during failures
Noticed that we were missing some information from the logs when looking at traces, adding those details to speed up turn around time.
1 parent a005934 commit 7585860

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

onedrivesdk/src/main/java/com/onedrive/sdk/authentication/ADALAuthenticator.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import com.microsoft.aad.adal.AuthenticationCallback;
3232
import com.microsoft.aad.adal.AuthenticationCancelError;
3333
import com.microsoft.aad.adal.AuthenticationContext;
34+
import com.microsoft.aad.adal.AuthenticationException;
3435
import com.microsoft.aad.adal.AuthenticationResult;
3536
import com.microsoft.aad.adal.PromptBehavior;
3637
import com.onedrive.sdk.core.ClientException;
@@ -394,7 +395,13 @@ public void onSuccess(final AuthenticationResult authenticationResult) {
394395

395396
@Override
396397
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,
398405
e,
399406
OneDriveErrorCodes.AuthenticationFailure));
400407
loginSilentWaiter.signal();
@@ -509,7 +516,13 @@ public void onError(final Exception ex) {
509516
code = OneDriveErrorCodes.AuthenticationCancelled;
510517
}
511518

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+
513526
error.set(new ClientAuthenticatorException(message, ex, code));
514527
mLogger.logError("Error while attempting to login interactively", error.get());
515528
discoveryCallbackWaiter.signal();
@@ -609,12 +622,18 @@ public void onSuccess(final AuthenticationResult authenticationResult) {
609622

610623
@Override
611624
public void onError(final Exception e) {
625+
String message = "Error while retrieving the service specific auth token";
612626
OneDriveErrorCodes code = OneDriveErrorCodes.AuthenticationFailure;
613627
if (e instanceof AuthenticationCancelError) {
614628
code = OneDriveErrorCodes.AuthenticationCancelled;
615629
}
630+
if (e instanceof AuthenticationException) {
631+
message = String.format("%s; Code %s",
632+
message,
633+
((AuthenticationException)e).getCode().getDescription());
634+
}
616635

617-
error.set(new ClientAuthenticatorException("Error while retrieving the service specific auth token",
636+
error.set(new ClientAuthenticatorException(message,
618637
e,
619638
code));
620639
mLogger.logError("Unable to refresh token into OneDrive service access token", error.get());

0 commit comments

Comments
 (0)