简体   繁体   English

使用 firebase 时出现 401 客户端错误

[英]Getting 401 Client Error when using firebase

I'm new to firebase and I'm trying to update some data in an existing project but I'm getting the following error: 401 Client Error: Unauthorized for url.我是 firebase 的新手,我正在尝试更新现有项目中的一些数据,但出现以下错误:401 Client Error: Unauthorized for url。 So how to fix this problem and thank you, I just want to mention also that I have been added to the project.那么如何解决这个问题,谢谢,我只想提一下我已被添加到项目中。 so I'm not the owner: this is my code:所以我不是所有者:这是我的代码:

from firebase import firebase

firebase = firebase.FirebaseApplication("the http path", None) # None bcz we are testing

firebase.put("/esco-lebanon/device-configs/atest-dev", "brightness", 50)

print("Updated")

According to the documentation , a 401 error means one of the following:根据文档,401 错误表示以下情况之一:

  • The auth token has expired.身份验证令牌已过期。
  • The auth token used in the request is invalid.请求中使用的身份验证令牌无效。
  • Authenticating with an access_token failed.使用 access_token 进行身份验证失败。
  • The request violates your Firebase Realtime Database Rules.该请求违反了您的 Firebase 实时数据库规则。

The understanding here is that your client code needs to correctly identify a Firebase Authentication user with a token in access_token , and that user account must have access to read the data in the database according to its security rules.这里的理解是,您的客户端代码需要使用access_token中的令牌正确识别 Firebase 身份验证用户,并且该用户帐户必须有权根据其安全规则读取数据库中的数据。 Since you haven't provided a token, your access is coming in anonymously, so you could only query data where security rules allow universal access.由于您没有提供令牌,因此您的访问是匿名的,因此您只能查询安全规则允许通用访问的数据。

If you haven't investigated using authentication in your request, you should read the documentation about that .如果您尚未调查在您的请求中使用身份验证,您应该阅读相关文档

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM