如何从Firebase身份验证正确获取Twitter screenName?

时间:2018-08-13 13:01:06

标签: node.js firebase firebase-authentication twitter-oauth

遵循这些链接https://firebase.google.com/docs/auth/web/manage-users#update_a_users_profilehttps://firebase.google.com/docs/auth/web/manage-users#get_a_users_provider-specific_profile_information

我能够验证用户身份并使用其Twitter帐户登录。但是,我想获取用户的screenName。我该怎么办?

我已经检查了一些网络请求,并且看到了screenName属性。我检查了onAuthStateChanged,它返回了user属性,但没有screenName

1 个答案:

答案 0 :(得分:-1)

请参阅Get a user's profile文档。 .displayName属性应该具有它。

var user = firebase.auth().currentUser; 
var name, email, photoUrl, uid, emailVerified;


if (user != null) {
  name = user.displayName;
  email = user.email;
  photoUrl = user.photoURL;
  emailVerified = user.emailVerified;
  uid = user.uid;  // The user's ID, unique to the Firebase project. Do NOT use
                   // this value to authenticate with your backend server, if
                   // you have one. Use User.getToken() instead.
}