firebase.auth.Auth.signInWithCredential is deprecated. Please use firebase.auth.Auth.signInAndRetrieveDataWithCredential instead
UPDATE 11 Dec. 2019
Note that the signInAndRetrieveDataWithCredential()
method has been deprecated and that we need to use the signInWithCredential()
method.
So, the code shall be adapted to
return this.afAuth.auth.signInWithCredential(
firebase.auth.GoogleAuthProvider.credential(gplusUser.idToken)
).then((credential) => {
console.log('creds', credential.user);
this.updateUserData(credential.user);
});
If I correctly understand your question, I think your problem comes from the fact that the two methods return a different object:
As explained here, signInWithCredential()
returns a User
object,
while
As explained here, signInAndRetrieveDataWithCredential()
returns a UserCredential
object, which contains a User
object.
So you should modify your code as follows
....
return this.afAuth.auth.signInAndRetrieveDataWithCredential(
firebase.auth.GoogleAuthProvider.credential(gplusUser.idToken)
).then((credential) => {
console.log('creds', credential.user);
this.updateUserData(credential.user);
});
I just want to clarify that signInAndRetrieveDataWithCredential
, and not the signInWithCredential
, has been deprecated in version 6 of the Firebase JS SDK.
Furthermore the function signInWithCredential
has now been updated to return a UserCredential
, so you should be able to access the uid, email, etc. under the user object on the UserCredential