[英]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);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.