简体   繁体   English

我可以通过 firebase 云功能管理员 SDK 访问 twitter 身份验证数据吗? 如果是这样,怎么做?

[英]Can I access twitter auth data via firebase cloud functions Admin SDK? If so, how?

I'm currently using firebase for the backend of a project I'm working on.我目前正在使用 firebase 作为我正在处理的项目的后端。 In this project, the client authenticates using the firebase-twitter sign in method.在这个项目中,客户端使用 firebase-twitter 登录方法进行身份验证。 For the purpose of security, I'm trying to minimise the amount of communication between the client and backend when it comes to auth data.为了安全起见,我试图在涉及身份验证数据时尽量减少客户端和后端之间的通信量。 In jest of this, I'm wondering if there is a way to access the auth data ie the user's twitter key/secret (as well as things like the user's twitter handle) from the server-side after the user authenticates?开玩笑地说,我想知道是否有一种方法可以在用户验证后从服务器端访问身份验证数据,即用户的 twitter 密钥/秘密(以及用户的 twitter 句柄之类的东西)? I figured there might be a way as the authentication happens through twitter + firebase, but I'm struggling to find the exact solution I need in the documentation (been stuck on this for a week now) so was hoping someone else already knows if this is possible and how:) cheers我想可能有一种方法可以通过 twitter + firebase 进行身份验证,但我很难在文档中找到我需要的确切解决方案(现在已经坚持了一周)所以希望其他人已经知道是否是可能的以及如何:) 欢呼

Maybe not the best way, but you can try: on client side use RealTime database and add a new entry every time the user log in. They call this 'realtime triggers'.也许不是最好的方法,但您可以尝试:在客户端使用实时数据库并在每次用户登录时添加一个新条目。他们称之为“实时触发器”。

You don't mention what front are you using, but on ionic is something like:你没有提到你使用的是什么前端,但在 ionic 上是这样的:

firebase.auth().onAuthStateChanged(function(user) {      

  if (user)
      this.db.addLogin(user.uid)               
 });  

On database class function:在数据库 class function 上:

 addLogin(uid){
  let path = "/logins/" 
  let ref = this.db.list(path)

  let body = {uid: uid}
  return ref.push(body)
 }      

On the server side, listen the path using child_added在服务器端,使用 child_added 监听路径

var ref = db.ref("logins");

ref.on("child_added", function(snapshot, prevChildKey) {
  var newPost = snapshot.val();
  console.log("Uid: " + newPost.uid);
  console.log("Previous Post ID: " + prevChildKey);
});

More information about triggers 有关触发器的更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在使用 Cloud Functions 时使用 Firebase Admin SDK 更改 Firebase 实时数据库中的数据? - How do I use Firebase Admin SDK to change data in Firebase Realtime Database while using Cloud Functions? Firebase 管理员 SDK 具有用于云存储的云功能 - Firebase Admin SDK with Cloud functions for cloud storage 如何在 firebase 管理员中测试云功能 Auth Trigger? - How to test cloud functions Auth Trigger in firebase admin? 无法在 Cloud Functions 中初始化 Firebase admin sdk - Cannot initialize Firebase admin sdk in Cloud Functions 我可以通过 Firebase Cloud Functions 压缩 Firebase 存储中的文件吗? - Can I zip files in Firebase Storage via Firebase Cloud Functions? 如何通过Firebase Cloud函数将数据写入/更新到多个子节点? - How do I write/update data to multiple child nodes via Firebase Cloud functions? 如何使用 firebase 管理员 SDK 创建具有社交提供者的租户? - How can I create a tenant with social provider with firebase admin SDK? 如何拒绝管理员调用Firebase功能? - How can I deny the admin from calling Firebase functions? 如何通过管理SDK登出用户? (使auth === null) - How to sign out the user via admin SDK? (make the auth === null) 如何使用 firebase admin SDK 访问 admin firestore? - How to access admin firestore using firebase admin SDK?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM