React-redux-firebase: Deprecated firebase.User.prototype.signInWithEmailAndPassword

Created on 15 May 2018  Â·  29Comments  Â·  Source: prescottprue/react-redux-firebase

Getting this console warning when logging in with username and password:

Deprecated firebase.User.prototype.signInWithEmailAndPassword in favor of firebase.User.prototype.signInAndRetrieveDataWithEmailAndPassword.

Using react-redux-firebase:2.1.1 together with react-native-firebase:4.1.0 – not entirely sure which of the two is causing this warning but I suspect it's react-redux-firebase as react-native-firebase should only be a native wrapper of the normal firebase sdk API methods.

enhancement help wanted

Most helpful comment

Released v2.2.4 with the change that only calls signInAndRetrieveDataWithEmailAndPassword if signInWithEmailAndPassword is not defined (so it won't be called if you are using the newest Firebase SDK version).

If anyone still sees warnings or incorrect behavior after updating to v2.2.4 reach out. Thanks to all for reporting

All 29 comments

@jaschaio Thanks for reporting. It seems like newer versions of the Firebase SDK (^v5.0.0) use these new methods.

Since folks still use this with older versions of Firebase (both JS SDK and react-native-firebase) we will have to include logic that uses signInAndRetrieveDataWithEmailAndPassword if it is available, but falls back to signInWithEmailAndPassword.

Reproduced the initial issue new Firebase version.

Weirdly, when putting this simple logic in place, I got a warning that is telling me the exact opposite?

image

Going to investigate more before making a change. Any input is welcome.

@jaschaio Just to confirm which method did you call to sign in?

@prescottprue getFirebase().login( data )

getFirebase() is the extra argument from react-redux-firebase added to my thunks with thunk.withExtraArgument( getFirebase )

Thought the code in v2.1.5 would fix the issue, but realizing it probably won't, since it was fixing it for the new token methods.

I am also seeing firebase.auth.Auth.prototype.signInAndRetrieveDataWithEmailAndPassword is deprecated. Please use firebase.auth.Auth.prototype.signInWithEmailAndPassword instead.

      emailLogin: ({ firebase, router, showError }) => creds =>
      firebase.login(creds).catch(err => showError(err.message)),

I am running "react-redux-firebase": "^2.1.5", and "firebase": "^5.0.4",

I'm seeing this as well. Oddly only sometimes. Can't really figure out when this is happening.

@fredrik-sogaard Interested. What are your versions of react-redux-firebase and firebase?

"firebase": "^5.0.4",
"react-redux-firebase": "^2.1.5",

Now I seem to get it every time. Screenshot: https://cl.ly/0q2U0Z07012D

I can try updating Firebase and react-redux-firebase to the latest release and see if that helps.

It's the same with Firebase 5.2.0 and react-redux-firebase 2.1.6.

I'm using "firebase": "^5.2.0", in my react-redux app, but without react-redux-firebase and am also receiving the warning. This is an issue with the firebase web SDK itself.

Anyone has a solution for this? I'm using "react-redux-firebase": "^2.1.8" and "firebase": "^5.4.2".

I also get the error showing up on concole sometimes...
As mentioned earlier, Firebase refactored this method on it's API recently, this is why it is happening
I'm unable to reproduce it at the moment....

It might comes from:

getLoginMethodAndParams()

Inside you have something like this

const emailPasswordAuth = firebase.auth()
.signInAndRetrieveDataWithEmailAndPassword

if (emailPasswordAuth) {
return {
method: 'signInAndRetrieveDataWithEmailAndPassword',
params: [email, password]
}
}

located in

react-redux-firebase/src/utils/auth.js

I found a similar issue with facebook login via signInWithCredential (signInAndRetrieveDataWithCredential in newer firebase). I've got a fix working essentially copying @kadikraman 's PR but for credential auth

Thanks @oacstevens! Added some comments pointing to this issue and released it in 2.1.9. Reach out if it doesn't fix the warning as expected.

For email login I still see the warning firebase.auth.Auth.prototype.signInAndRetrieveDataWithEmailAndPassword is deprecated. Please use firebase.auth.Auth.prototype.signInWithEmailAndPassword instead. No warning anymore for credential login (only tested facebook).

Need to look in more detail, but after a quick look though the firebase docs it appears to me that somewhat confusingly for email login signInAndRetrieveDataWithEmailAndPassword is deprecated and replaced with signInWithEmailAndPassword, but for credential auth it's the other way round and signInAndRetrieveDataWithCredential is the new method

Despite the warning email login actually still works for me, but I found the credential login was broken. Whilst the the old method did sign the user in it didn't retrieve user data in the newer versions of firebase.

I haven't done detailed testing, but for me it seems like this happens when I'm already logged in and try to log in again.

I tried flipping the logic around in /src/utils/auth.js so signInWithEmailAndPassword is attempted first (falling back to signInAndRetrieveDataWithEmailAndPassword), and that gets rid of the warning on firebase 5.5.5. My guess is that if the new method didn't exist in firebase 4.x then this flip would work there too? I hope I'm not the only one that's a bit confused though, this seems the opposite of the error that started this issue!

Looking in the firebase js sdk here signInAndRetrieveDataWithEmailAndPassword is deprecated so shows a warning, but passes through to signInWithEmailAndPassword. I think that explains why I found it was working despite the warning.

I'm not familiar with the firebase sdk history, but I'm looking though the auth history to see what older versions did

Reopening since there are some situations where this still appears

I also still face this warning using the email login method. For the credential login it seems indeed to be gone.

Version:
react-redux-firebase: "2.2.3"

I'm also receiving a warning firebase.auth.Auth.prototype.signInAndRetrieveDataWithEmailAndPassword is deprecated. Please use firebase.auth.Auth.prototype.signInWithEmailAndPassword instead.
on use this.props.firebase.login({ username, password }).

"react-redux-firebase": "^2.2.3",

@DickerHobbit and @kdela thanks for reaching out. When looking back at it, it seems there was logic calling signInAndRetrieveDataWithEmailAndPassword but it was pointing to this issue number. That makes me think that there are different warnings based on the version of Firebase's JS SDK you are using, but with the newest one the warning went away by just removing that logic (doing as part of next release).

Released v2.2.4 with the change that only calls signInAndRetrieveDataWithEmailAndPassword if signInWithEmailAndPassword is not defined (so it won't be called if you are using the newest Firebase SDK version).

If anyone still sees warnings or incorrect behavior after updating to v2.2.4 reach out. Thanks to all for reporting

Hello, if you are following Brad Traversy's React Front to Back Course from Udemy and getting this warning, you should use following code
firebase.auth().signInWithEmailAndPassword(email, password).catch(err => notifyUser('Invalid Login Credentials', 'error'));

Do not use below code from the original tutorial.
firebase.login({email,password}).catch(err => notifyUser('Invalid Login Credentials', 'error')); };

@chethanbhat Thanks for reaching out about the context for the tutorial. Something to note is that doing that will mean that one won't get the functionality listed with login like profile creation.

With newer versions of react-redux-firebase you shouldn't get the warning even when using login. If anyone is still seeing the warning we should reopen this issue.

Hi,

Apparently signInAndRetrieveDataWithCredential is deprecated and signInWithCredential is the new method now.

This code is supposed to only run it if it exists, but maybe that logic should just be removed all together if it throws this warning.

Was this page helpful?
0 / 5 - 0 ratings