[英]Could not parse auth token (Firebase)
I am trying to save data in my firebase realtime database using this rule:我正在尝试使用以下规则将数据保存在我的 firebase 实时数据库中:
{
"rules": {
"users": {
"$uid": {
// Allow only authenticated content owners access to their data
".read": "auth != null && auth.uid == $uid",
".write": "auth != null && auth.uid == $uid",
},
},
},
}
I need to create a child of users and name it the uid of that user.我需要创建一个用户的孩子并将其命名为该用户的 uid。 So, I did this:所以,我这样做了:
user=auth.sign_in_with_email_and_password('email', 'password')
database.child('users').child(user['localId']).set("nahid",user['localId'])
but when I run this, I get this error:但是当我运行这个时,我收到这个错误:
requests.exceptions.HTTPError: [Errno 401 Client Error: Unauthorized for url: https://khelobd-6f730-default-rtdb.firebaseio.com/users/7Km7srPfqqccZwa0On5i2QaJDUi2.json?auth=7Km7srPfqqccZwa0On5i2QaJDUi2] {
"error" : "Could not parse auth token."
}
How can I solve this?我该如何解决这个问题?
The ?auth=
param does not seems to be user's Firebase ID Token but the UID itself. ?auth=
param 似乎不是用户的 Firebase ID 令牌,而是 UID 本身。 Try changing user['localId']
in set()
to user['idToken']
:尝试改变user['localId']
在set()
到user['idToken']
user=auth.sign_in_with_email_and_password('email', 'password')
database.child('users').child(user['localId']).set("nahid",user['idToken'])
# ^^^
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.