【问题标题】:Can I access twitter auth data via firebase cloud functions Admin SDK? If so, how?我可以通过 Firebase 云功能 Admin SDK 访问 twitter 身份验证数据吗?如果是这样,怎么做?
【发布时间】:2021-04-05 16:31:30
【问题描述】:

我目前正在将 firebase 用于我正在处理的项目的后端。在这个项目中,客户端使用 firebase-twitter 登录方法进行身份验证。为了安全起见,我试图在涉及身份验证数据时尽量减少客户端和后端之间的通信量。开这个玩笑,我想知道是否有一种方法可以在用户认证后从服务器端访问身份验证数据,即用户的 twitter 密钥/秘密(以及用户的 twitter 句柄之类的东西)?我认为可能有一种方法可以通过 twitter + firebase 进行身份验证,但我正在努力在文档中找到我需要的确切解决方案(现在已经坚持了一周)所以希望其他人已经知道如果这个是可能的,如何:) 干杯

【问题讨论】:

    标签: node.js firebase twitter firebase-authentication google-cloud-functions


    【解决方案1】:

    也许不是最好的方法,但您可以尝试:在客户端使用实时数据库并在每次用户登录时添加一个新条目。他们称之为“实时触发器”。

    你没有提到你使用的是什么前端,但在 ionic 上是这样的:

    firebase.auth().onAuthStateChanged(function(user) {      
    
      if (user)
          this.db.addLogin(user.uid)               
     });  
    

    关于数据库类函数:

     addLogin(uid){
      let path = "/logins/" 
      let ref = this.db.list(path)
    
      let body = {uid: uid}
      return ref.push(body)
     }      
    

    在服务器端,使用 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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-08
      • 2019-09-01
      • 2019-07-09
      • 1970-01-01
      • 2021-06-30
      • 2017-11-14
      相关资源
      最近更新 更多