【问题标题】:How to properly get Twitter screenName from firebase auth?如何从 firebase auth 正确获取 Twitter screenName?
【发布时间】:2018-08-13 13:01:05
【问题描述】:

点击这些链接 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

【问题讨论】:

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


【解决方案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.
}

【讨论】:

  • screenName 是 Twitter 的用户名属性。即@twitter。似乎currentUser 没有提供像screenName 这样的附加信息
猜你喜欢
  • 1970-01-01
  • 2023-03-18
  • 1970-01-01
  • 2018-09-24
  • 2021-05-08
  • 1970-01-01
  • 1970-01-01
  • 2018-10-24
  • 1970-01-01
相关资源
最近更新 更多