How to get Facebook ID from Firebase Admin?

后端 未结 1 357
我寻月下人不归
我寻月下人不归 2021-01-28 18:11

I\'m using Firebase Admin for login in my NodeJs app. Client will login by sending an idToken (which is get from Firebase), and then NodeJs server will get the user by using adm

相关标签:
1条回答
  • 2021-01-28 18:48

    That specific information will not be available in the ID token. You will need to use the Firebase Admin SDK to lookup the user and inspect the providerData:

    admin.auth().getUser(uid)
      .then(function(userRecord) {
        // Assuming the first provider linked is facebook.
        // The facebook ID can be obtained as follows.
        console.log(userRecord.providerData[0].uid);
      })
      .catch(function(error) {
        console.log("Error fetching user data:", error);
      });
    
    0 讨论(0)
提交回复
热议问题