0
votes

I use Firebase Authentication for a React Native project

React-native: 0.44.2 Firebase: 4.1.1

Initially I'm using signInAnonymously then I retrieve the token. After I use the token for authentications (signInWithCustomToken) but I always have auth/invalid-custom-token

Does someone have an idea?

Thank you

1

1 Answers

0
votes

When you signInAnonymously, you are already signed in and the ID token is not a custom token. You can't sign in with that. If you want to make sure the session is maintained the next time the app is restarted, use:

firebase.auth().onAuthStateChanged(function(user) { if (user) { // User signed in. firebase.auth().currentUser is not null. } else { // No user signed in. } })