Aws-sdk-android: cognitoauth: Erroneous "user cancelled" AuthNavigationException Thrown by AuthClient

Created on 11 Aug 2017  路  11Comments  路  Source: aws-amplify/aws-sdk-android

To help us solve your problem better, please answer the following list of questions.

  • What service are you using?

    • Cognito
  • In what version of SDK are you facing the problem?

    • 2.4.7
  • Is the issue limited to Simulators / Actual Devices?

    • Occurs on both
  • Can your problem be resolved if you bump to a higher version of SDK?

    • No; using highest
  • Is this problem related to specific Android/OS version?

    • No
  • Can you give us steps to reproduce with a minimal, complete, and verifiable example? Please include any specific network conditions that might be required to reproduce the problem.

    1. Clone and build the AmazonCognitoAuthDemo project from aws-sdk-android-samples
    2. Update the values in the project's strings.xml
    3. In com.amazonaws.cognito.android.samples.authdemo.MainActivity, add logic to callback.onFailure() that logs the message and stack trace of the Exception that is passed to the method in logcat
    4. Build, run, and monitor logcat
    5. After signing in, when the custom Chrome tab closes, the error is thrown
  • Please include a stacktrace if applicable.

com.amazonaws.mobileconnectors.cognitoauth.exceptions.AuthNavigationException: user cancelled
   at com.amazonaws.mobileconnectors.cognitoauth.AuthClient$4.onNavigationEvent(AuthClient.java:559)
   at android.support.customtabs.CustomTabsClient$2.onNavigationEvent(CustomTabsClient.java:189)
   at android.support.customtabs.ICustomTabsCallback$Stub.onTransact(ICustomTabsCallback.java:61)
   at android.os.Binder.execTransact(Binder.java:565)
  • General description of the issue:

    • As a part of the AuthClient class, the SDK implements the onNavigationEvent() to monitor the Chrome custom tab that is used to facilitate authentication. If the event received equals ClientConstants.CHROME_NAVIGATION_CANCELLED (which is set to 6), an instance of AuthNavigationException with the message "user cancelled" is passed back to the onFailure() method of the callback set for the AuthClient class.

    • However, according to the documentation on Android's CustomTabsCallback, an event with the value of 6 is thrown on the TAB_HIDDEN event.

    • As a result, the "user cancelled" exception is not only thrown when a user closes/cancels the Chrome custom tab, but also under many other circumstances when the tab becomes hidden, including when the tab becomes hidden after successful authentication.

Bug Cognito Needs Info from Requester closing-soon-if-no-response

Most helpful comment

I am still getting the same issue with latest AWS SDK
along with that at the time of sing out its throwing below exception
" Access Token does not have required scopes "
If anyone got the solution kindly please help me out
Thank You

All 11 comments

Thank you for reporting this bug, we are investigating it.

Has anybody found a possible workaround?

Hello, I still have this issue with the last version of the AWS SDK. Someone found the way to solve this ?

Hello, every time the user gets redirected back to the app they will receive the error, "user canceled". The culprit is this snippet of code in the AuthClient.

/**
 * Callback for Custom Tabs to track navigation.
 */
private final CustomTabsCallback customTabsCallback = new CustomTabsCallback() {
    @Override
    public void onNavigationEvent(final int navigationEvent, final Bundle extras) {
        super.onNavigationEvent(navigationEvent, extras);
        if (navigationEvent == ClientConstants.CHROME_NAVIGATION_CANCELLED) {
            userHandler.onFailure(new AuthNavigationException("user cancelled"));
        }
    }
};

Ignore this and consider it log verbosity 'information'. This will not prevent other errors from being thrown or the success of authentication, it really only signifies that the user was redirected back into the app via the redirect link (your uri). Although I will be the first to admit that it is extremely annoying as the onFailure callback can potentially be processed multiple times in one instance, once for the user cancelled and another for actual errors e.g. InvalidParamterException or AuthServiceException

Hi,
is there any plan to fix this issue? It's quite difficult to distinguish between a real error or just a "log information".

Hi @kyarosh @erodewald @emax77 @drxeno02 @Plinzen ,

Please see if SDK release 2.12.5 fixes this issue for you.

You may see all changes in the changelog

Hi @minbi
although i updated SDK to 2.12.5 or 2.12.7, error still does occur.

Step to reproduce:

  1. I signed in app and then i Sign out with AWSMobleClient.getInstance.SignOut()
  2. I press sign in google/facebook button (signed in google/facebook account). it goes to facebook/google page and call back with "user canceled" error. but when i press the button again the result of call back is "signed in succeeded".

note: it means that if I sign out and want to sign in again. I have to press sign in button twice to sign in successfully.
firsth: call back "user canceled"
secondth: "signed in"

I'm waiting for your feedback.

Hi,

Please see if SDK release 2.13.2 fixes this issue for you. We have added the following bug fixes:

Fixed erroneous user cancelled error when redirecting back to app.

You may see all changes in the changelog

This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.

I am still getting the same issue with latest AWS SDK
along with that at the time of sing out its throwing below exception
" Access Token does not have required scopes "
If anyone got the solution kindly please help me out
Thank You

I've found a fix, I've commented here https://github.com/aws-amplify/aws-sdk-android/issues/871#issuecomment-608355327

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pedronveloso picture pedronveloso  路  3Comments

ansuman87 picture ansuman87  路  4Comments

zgao67 picture zgao67  路  4Comments

amadeu01 picture amadeu01  路  3Comments

nsadiq-radpits picture nsadiq-radpits  路  3Comments