Firebase Google Auth Web JS

I am successfully integrated firebase google auth web. I was getting this below response. how can i get only additionalUserInfo in js This is response after successfully sign in This is code

function googleSignin() {
    base_proveider =new firebase.auth.GoogleAuthProvider()
    firebase.auth().signInWithPopup(base_proveider).then(function(result){
        console.log(result)
        console.log("success google account linked")
    }).catch(function(err){
        console.log(err)
        console.log('fialed to do')

    })
  }
评论
uqui
uqui

As you can read in the doc for signInWithPopup(), it returns a Promise which resolves with a UserCredential, which is "a structure containing a User, an AuthCredential, the operationType, and any additional user information that was returned from the identity provider".

因此,您必须执行以下操作:

firebase.auth().signInWithPopup(base_proveider)
.then(function(result){  
    // result is a UserCredential
    var additionalUserInfo = result.additionalUserInfo;

    console.log(result)
    console.log("success google account linked")
})
点赞
评论