Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

addOnFailureListener not trigger when user dismiss the verify dialog #12

Open
vsay01 opened this issue Mar 7, 2018 · 8 comments
Open

Comments

@vsay01
Copy link

vsay01 commented Mar 7, 2018

library version used: com.google.android.gms:play-services-safetynet:11.4.2

I am using safety net captcha API. everything working as expected meaning, both are detected:

  • on success (when test with real device and no harms detected)
  • one failure listener (when test with Android emulator and verified the steps)

However, Here steps produce issue where on success and on failure are not detected:

  • Run app in Android emulator
  • Hit the SafetyNet verify with captcha
  • As android emulator mark as possible harm, it will shows image for the verification
  • Click on listen icon to listen the word
  • Click on the screen outside the dialog area, the verification dialog will close

Expected: addOnFailureListener should be triggered because user didn't response to the verification steps when detected as robot

Actual: both OnSuccessListener and addOnFailureListener are not detected

Code:

SafetyNet.getClient(this).verifyWithRecaptcha(YOUR_API_SITE_KEY)
            .addOnSuccessListener((Executor) this,
            new OnSuccessListener<SafetyNetApi.RecaptchaTokenResponse>() {
                @Override
                public void onSuccess(SafetyNetApi.RecaptchaTokenResponse response) {
                    // Indicates communication with reCAPTCHA service was
                    // successful.
                    String userResponseToken = response.getTokenResult();
                    if (!userResponseToken.isEmpty()) {
                        // Validate the user response token using the
                        // reCAPTCHA siteverify API.
                    }
                }
        })
        .addOnFailureListener((Executor) this, new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    if (e instanceof ApiException) {
                        // An error occurred when communicating with the
                        // reCAPTCHA service. Refer to the status code to
                        // handle the error appropriately.
                        ApiException apiException = (ApiException) e;
                        int statusCode = apiException.getStatusCode();
                        Log.d(TAG, "Error: " + CommonStatusCodes
                                .getStatusCodeString(statusCode));
                    } else {
                        // A different, unknown type of error occurred.
                        Log.d(TAG, "Error: " + e.getMessage());
                    }
                }
        });

Questions:

  • Is it expected design in which if user dismiss the verification dialog then SafetyNet doesn't notify the listener?
  • Are there any other listener for SafetyNet to handle the scenario above of the issue? or other solutions to handling this scenario from SafetyNet SDK?

Thanks

@iiw
Copy link

iiw commented Feb 21, 2019

Hello. Did you found solution for that?

@vsay01
Copy link
Author

vsay01 commented Mar 1, 2019

@iiw what we end up doing is dismiss all dialogs in onResume.
I still think it would be nice to have the listener for this though.
Hope it help.

@iiw
Copy link

iiw commented Mar 1, 2019

I did same. Thanks.

@gildor
Copy link

gildor commented Oct 29, 2020

I'm pretty sure it's a bug, Recaptcha should support or pass cancellation to addOnFailureListener, which I believe correct approach (because it's also the result of the operation), or at least trigger addOnCanceledListener, which also a solution, but I think it not so straightforward, an internal result of the task shouldn't cancel it

@vedraj360
Copy link

@vsay01 can you explain it more clearly when you are dismissing the dialog and how you know dialog is dismissed.

@mayuce
Copy link

mayuce commented Dec 6, 2021

It has been years over it but still it's an open issue, that is nasty...

@chowdarym05
Copy link

addOnCanceledListener is still not triggered. Not sure when this issue will be addressed.

@TareqAmenahDev
Copy link

5 years and still have this issue..

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants