Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The request is missing the reCaptcha token #1634

Closed
mwaked opened this issue Jun 9, 2020 · 6 comments
Closed

The request is missing the reCaptcha token #1634

mwaked opened this issue Jun 9, 2020 · 6 comments

Comments

@mwaked
Copy link

mwaked commented Jun 9, 2020

Hello,
I hope all is well,
I use firebase phone authentication and this error message "The request is missing the reCaptcha token" is return in onVerificationFailed method only on some Android devices, why this error happened? and how can i fix this error?

Device Details

  • Device: Huawei
  • Android version: Android 10
  • Google Mobile Services (GMS) is available

Android Code

PhoneAuthProvider.getInstance().verifyPhoneNumber(
        phoneNumber,
        60,
        TimeUnit.SECONDS,
        this,
        mCallbacks);

private PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {

    @Override
    public void onVerificationFailed(@NonNull FirebaseException e) {
      
        Log.w(TAG, "onVerificationFailed", e);

    }

    @Override
    public void onVerificationCompleted(@NonNull PhoneAuthCredential credential) {

        Log.d(TAG, "onVerificationCompleted: " + credential);

    }

    @Override
    public void onCodeSent(@NonNull String verificationId,
                           @NonNull PhoneAuthProvider.ForceResendingToken token) {

        Log.d(TAG, "onCodeSent:" + verificationId);

    }
};

@Override
public void onOtpCompleted(String otp) {
   PhoneAuthCredential credential = PhoneAuthProvider.getCredential(mVerificationId, otp);
 sigintWithCredential(credential);
}
private void sigintWithCredential(PhoneAuthCredential credential) {
    showLoadingView();

    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, task -> {
                if (task.isSuccessful()) {

                    Log.d(TAG, "signInWithCredential:success");

                    FirebaseUser user = Objects.requireNonNull(task.getResult()).getUser();

                } else {

                    String errorMessage = Objects.requireNonNull(task.getException()).getLocalizedMessage();

                    if (task.getException() instanceof FirebaseAuthInvalidCredentialsException) errorMessage = getString(R.string.invalid_code);

                    Log.w(TAG, "signInWithCredential:failure", task.getException());

     

                }
            });

}
@google-oss-bot
Copy link
Contributor

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@CoderJava
Copy link

Yeah

Hello,
I hope all is well,
I use firebase phone authentication and this error message "The request is missing the reCaptcha token" is return in onVerificationFailed method only on some Android devices, why this error happened? and how can i fix this error?

Device Details

  • Device: Huawei
  • Android version: Android 10
  • Google Mobile Services (GMS) is available

Android Code

PhoneAuthProvider.getInstance().verifyPhoneNumber(
        phoneNumber,
        60,
        TimeUnit.SECONDS,
        this,
        mCallbacks);

private PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {

    @Override
    public void onVerificationFailed(@NonNull FirebaseException e) {
      
        Log.w(TAG, "onVerificationFailed", e);

    }

    @Override
    public void onVerificationCompleted(@NonNull PhoneAuthCredential credential) {

        Log.d(TAG, "onVerificationCompleted: " + credential);

    }

    @Override
    public void onCodeSent(@NonNull String verificationId,
                           @NonNull PhoneAuthProvider.ForceResendingToken token) {

        Log.d(TAG, "onCodeSent:" + verificationId);

    }
};

@Override
public void onOtpCompleted(String otp) {
   PhoneAuthCredential credential = PhoneAuthProvider.getCredential(mVerificationId, otp);
 sigintWithCredential(credential);
}
private void sigintWithCredential(PhoneAuthCredential credential) {
    showLoadingView();

    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, task -> {
                if (task.isSuccessful()) {

                    Log.d(TAG, "signInWithCredential:success");

                    FirebaseUser user = Objects.requireNonNull(task.getResult()).getUser();

                } else {

                    String errorMessage = Objects.requireNonNull(task.getException()).getLocalizedMessage();

                    if (task.getException() instanceof FirebaseAuthInvalidCredentialsException) errorMessage = getString(R.string.invalid_code);

                    Log.w(TAG, "signInWithCredential:failure", task.getException());

     

                }
            });

}

I have the same problem.

@herotha
Copy link

herotha commented Sep 16, 2020

I meet this problem too.
Here log from crashlytic.
image text
image text

@malcolmdeck
Copy link
Contributor

Hey folks,

I can speak to this one a little bit. There are two pieces here.

(1) Our error code says the wrong thing - I've filed b/169071896 to track that getting fixed internally.
(2) These devices aren't passing security checks when contacting our Phone Authentication APIs. There's no real remedy to this right now - some users use rooted or otherwise tampered-with Android devices, and that's not allowed when calling our Phone Auth APIs.

Hope that helps!
~Malcolm

@sotiris08
Copy link

What about the emulators?

@malcolmdeck
Copy link
Contributor

I should have closed this issue a while ago - it is no longer relevant to how new versions of the SDK function.

@sotiris08 if you're having an problem, please file a new Github issue with the details of what you're seeing :)

@firebase firebase locked and limited conversation to collaborators Feb 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants