带有ID令牌的REST API Firestore身份验证 [英] REST API Firestore authentication with ID Token
问题描述
我有一个Firestore数据库和一个用户.在用户通过REST请求登录后,我能够为该用户检索ID令牌.
I have a Firestore DB and one user. I am able to retrieve an ID Token for the user after they sign-in via a request with REST.
我将ID令牌用于从数据库读取/写入的请求.
I am to use the ID Token with requests to read/write from the DB.
以这种方式通过Python请求打开安全规则(任何人都可以读/写)时,我能够读写Firestore:
I am able to read and write to the Firestore when the security rules are open (anyone can read/write) in this manner, with Python requests:
headers = {
'Content-Type': 'application/json',
}
url = 'https://firestore.googleapis.com/v1beta1/projects/[PROJECT_NAME]/databases/(default)/documents/[COLLECTION]/[DOCUMENT]'
r = requests.get(url, headers=headers)
文字相似,因此省略.
尝试按照这些实时数据库文档的说明附加ID令牌给出错误消息""Invalid JSON payload received. Unknown name \"auth\""...
Attempting to append the ID Token as indicated by these docs for Realtime Database gives the error message ""Invalid JSON payload received. Unknown name \"auth\""...
我的问题是如何通过REST为Firestore授权用户ID令牌?
My question is how to authorise a user ID Token for Firestore via REST?