Android Firebase phone authentication INVALID_APP_CREDENTIAL:App validation failed

Coozgan

I am really new to android firebase and I have implemented the necessary libraries for Firebase Auth. I try putting a valid number, but the log says its:

W/JEJE: onVerificationFailed
com.google.firebase.FirebaseException: An internal error has occurred. [ INVALID_APP_CREDENTIAL:App validation failed ]
at com.google.android.gms.internal.nf.zzK(Unknown Source)
at com.google.android.gms.internal.og.zza(Unknown Source)
at com.google.android.gms.internal.oh.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6176)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)

Here is my code:

public class MainActivity extends AppCompatActivity {

    private static String mVerificationId;
    private static PhoneAuthProvider.ForceResendingToken mResendToken;
    private static FirebaseAuth mAuth;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final EditText editText = (EditText) findViewById(R.id.phone);
        Button submit = (Button) findViewById(R.id.submit);

        final PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallBacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
            @Override
            public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
                Log.d("JEJE", "onVerificationCompleted:" + phoneAuthCredential);

                signInWithPhoneAuthCredential(phoneAuthCredential);
            }

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

                if (e instanceof FirebaseAuthInvalidCredentialsException) {
                    Log.d("JEJE", "INVALID REQUEST");
                } else if (e instanceof FirebaseTooManyRequestsException) {
                    Log.d("JEJE", "Too many Request");
                }
            }

            @Override
            public void onCodeSent(String s, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
                super.onCodeSent(s, forceResendingToken);
                Log.d("JEJE", "onCodeSent:" + s);

                mVerificationId = s;
                mResendToken = forceResendingToken;

            }
        };

        submit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String phoneNum = editText.getText().toString();
                Toast.makeText(MainActivity.this, phoneNum, Toast.LENGTH_SHORT).show();
                verifyPhone(phoneNum,mCallBacks);
            }

        });
    }

    private void signInWithPhoneAuthCredential(PhoneAuthCredential phoneAuthCredential) {
        mAuth.signInWithCredential(phoneAuthCredential).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
            @Override
            public void onComplete(@NonNull Task<AuthResult> task) {
                if (task.isSuccessful()){
                    FirebaseUser user = task.getResult().getUser();
                }else {
                    if (task.getException() instanceof FirebaseAuthInvalidCredentialsException) {
                        // The verification code entered was invalid
                    }
                }
            }
        });
    }

    public void verifyPhone(String phoneNumber, PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallbacks){
        PhoneAuthProvider.getInstance().verifyPhoneNumber(
                "+639952874699",        // Phone number to verify
                60,                 // Timeout duration
                TimeUnit.SECONDS,   // Unit of timeout
                this,               // Activity (for callback binding)
                mCallbacks);        // OnVerificationStateChangedCallback
    }

}

please tell me whats wrong thanks..

Coozgan

Adding SHA Certificate Fingerprint solves my problem. Well, Im fairly new to this but I managed to show output and I was able to received a sms verification.

For reference here are my codes: https://github.com/coozgan/TestingPhoneAuth

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Android Firebase電話認証INVALID_APP_CREDENTIAL:アプリの検証に失敗しました

分類Dev

How to set the callbacks for Android Firebase Phone Authentication?

分類Dev

How to change the Signed in Phone Number in Firebase Authentication for Android?

分類Dev

Facebook authentication via android app

分類Dev

Using Firebase Authentication with new @App protocol

分類Dev

Android app updating to Amazon App Store failed

分類Dev

Android App installation on phone for testing : Suggestions

分類Dev

Firebase Phone Authentication AndroidでSMS確認を再送信する方法

分類Dev

React-native-firebase phone authentication

分類Dev

Flutter app crashes on firebase phone auth in iOS platform

分類Dev

Flutter app crashes on firebase phone auth in iOS platform

分類Dev

Firebase Authentication - How do I structure my react native app?

分類Dev

Android Studio 2.0 Preview: ':app:transformClassesWithInstantRunForDebug' FAILED

分類Dev

Android - Build Failed error While Running an App

分類Dev

How to detect programmatically if "Android App" is running in chrome book or in Android phone

分類Dev

Sending a Welcome email using Google Cloud Functions when the app uses Phone verification for authentication

分類Dev

Replacing default Phone app on Android 6 and 7 with InCallService

分類Dev

Can a BLE peripheral connect to a background app on an Android phone?

分類Dev

Can't install Titanium's app on my android 2.3.6 phone

分類Dev

Android biometric authentication invalid variables in AuthenticationCallback when using device credential

分類Dev

In-app purchases (IAP) in android with BOTH Google and Facebook authentication?

分類Dev

Android app custom web service authentication using HttpPost does not stick

分類Dev

Listen to Firebase DB changes in background of Android app

分類Dev

OutOfMemoryException in Windows Phone app

分類Dev

App crashes and restarts phone

分類Dev

App fails to connect to MongoDB Enterprise with "Authentication failed" and Ops Manager stuck in "AdjustUsers"

分類Dev

Mobile App Authentication

分類Dev

Value of auth.provider for Phone Authentication & Facebook in Firebase Database

分類Dev

Redirect users depending upon their role after firebase phone authentication

Related 関連記事

  1. 1

    Android Firebase電話認証INVALID_APP_CREDENTIAL:アプリの検証に失敗しました

  2. 2

    How to set the callbacks for Android Firebase Phone Authentication?

  3. 3

    How to change the Signed in Phone Number in Firebase Authentication for Android?

  4. 4

    Facebook authentication via android app

  5. 5

    Using Firebase Authentication with new @App protocol

  6. 6

    Android app updating to Amazon App Store failed

  7. 7

    Android App installation on phone for testing : Suggestions

  8. 8

    Firebase Phone Authentication AndroidでSMS確認を再送信する方法

  9. 9

    React-native-firebase phone authentication

  10. 10

    Flutter app crashes on firebase phone auth in iOS platform

  11. 11

    Flutter app crashes on firebase phone auth in iOS platform

  12. 12

    Firebase Authentication - How do I structure my react native app?

  13. 13

    Android Studio 2.0 Preview: ':app:transformClassesWithInstantRunForDebug' FAILED

  14. 14

    Android - Build Failed error While Running an App

  15. 15

    How to detect programmatically if "Android App" is running in chrome book or in Android phone

  16. 16

    Sending a Welcome email using Google Cloud Functions when the app uses Phone verification for authentication

  17. 17

    Replacing default Phone app on Android 6 and 7 with InCallService

  18. 18

    Can a BLE peripheral connect to a background app on an Android phone?

  19. 19

    Can't install Titanium's app on my android 2.3.6 phone

  20. 20

    Android biometric authentication invalid variables in AuthenticationCallback when using device credential

  21. 21

    In-app purchases (IAP) in android with BOTH Google and Facebook authentication?

  22. 22

    Android app custom web service authentication using HttpPost does not stick

  23. 23

    Listen to Firebase DB changes in background of Android app

  24. 24

    OutOfMemoryException in Windows Phone app

  25. 25

    App crashes and restarts phone

  26. 26

    App fails to connect to MongoDB Enterprise with "Authentication failed" and Ops Manager stuck in "AdjustUsers"

  27. 27

    Mobile App Authentication

  28. 28

    Value of auth.provider for Phone Authentication & Facebook in Firebase Database

  29. 29

    Redirect users depending upon their role after firebase phone authentication

ホットタグ

アーカイブ