I'm trying to implement google reCaptcha following this guide from google developers site. My code:
private fun onClick() {
SafetyNet.getClient(this).verifyWithRecaptcha(CAPTCHA_KEY)
.addOnSuccessListener(this) { response ->
if (!response.tokenResult.isEmpty()) {
verify(response.tokenResult)
}
}
.addOnFailureListener(this) { e ->
if (e is ApiException) {
Log.d("asd", "Error message: " + CommonStatusCodes.getStatusCodeString(e.statusCode))
} else {
Log.d("asd", "Unknown type of error: " + e.message)
}
}
}
On emulator its work fine. When i click on button, reCaptcha show dialogs with several images where user should pick all images with cars, gidrants etc.
But, on real device. After i click on button, i always receive onSuccess callback, and the dialog never shown.
Maybe somebody know what the problem i faced?
Per the documentation:
If reCAPTCHA is confident that this is a real user on a real device it will return a token with no challenge. Otherwise it will provide a visual/audio challenge to attest the humanness of the user before returning a token.
"No challenge" means no reCAPTCHA. With reference to your real device, Google is apparently already satisified as to your humanness, and does not require further confirmation.
verifyWithRecaptcha()
is operating as designed.