简体   繁体   中英

Android Firebase authentication issue

I'm trying to login with Firebase authentication but I'm getting a FirebaseException. In my activity I have the onCreate method:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mAuth = FirebaseAuth.getInstance();
        android.support.v7.app.ActionBar actionBar = getSupportActionBar();
        actionBar.setTitle(R.string.title_calendar);
        initData();

    }

The onStart method:

@Override
    protected void onStart() {
        super.onStart();

        FirebaseUser user = mAuth.getCurrentUser();
        if (user != null) {
            // something
        } else {
            signIn();
        }
    }

and the signIn method:

private void signIn() {
        mAuth.signInWithEmailAndPassword("test@abc.com", "123456789").addOnSuccessListener(this, new  OnSuccessListener<AuthResult>() {
            @Override
            public void onSuccess(AuthResult authResult) {
                Log.i("Log", "signIn:SUCCESS");
            }
        })
                .addOnFailureListener(this, new OnFailureListener() {
                    @Override
                    public void onFailure(@NonNull Exception exception) {
                        Log.e("Log", "signIn:FAILURE", exception);
                    }
                });
    }

I'm getting this:

E/shinseiLog: signIn:FAILURE
    com.google.firebase.FirebaseException: An internal error has occurred. [ Identity Toolkit API has not been used in project 611854850952 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/identitytoolkit.googleapis.com/overview?project=611854850952 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry. ]
        at com.google.android.gms.internal.jz.zzK(Unknown Source:147)
        at com.google.android.gms.internal.jb.zza(Unknown Source:12)
        at com.google.android.gms.internal.kj.zzL(Unknown Source:11)
        at com.google.android.gms.internal.kl.onFailure(Unknown Source:35)
        at com.google.android.gms.internal.kb.onTransact(Unknown Source:79)
        at android.os.Binder.execTransact(Binder.java:697)

the authentication method email, password is enabled on firebase console and also Identity Toolkit API.

Please Check Your Project Existing firebase console using following URL https://console.firebase.google.com If is it available rebuild your project using Build -> Rebuild Project and Resync your project using Gradle Files

Sync With GradleFiles Icon

Is your google-services.json file from Firebase up to date? As you enable services in Firebase that JSON gets updates. Try re-downloading it from Firebase and check if it is different?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM