Tip: From Visual Studio Code, you can use the command DeviceScript: Report Issue... to prefill the issue template.
Describe the bug
From a ESP32 device, I want to post some data to a Cloud Firestore, thus I'm using fetch(...) function to achieve that.
The store is currently unprotected for the moment, so any data can be posted without much overhead.
Thing is, I get a socket tls://firestore.googleapis.com:443 error tls://firestore.googleapis.com:443: self-signed certificate.
This is my code:
const url = `https://firestore.googleapis.com/v1/projects/{PROJECT_ID}/databases/(default)/documents/{COLLECTION_ID}`
const options = {
method: "POST",
body: JSON.stringify(...),
headers: { "Content-Type": "application/json", key: API_KEY }
}
const response = await fetch(url, options)
//...
NOTE: I tried exactly the same with MicroPython, and works like a charm.
Here is my python code:
import urequests
#...
response = urequests.post(
f'https://firestore.googleapis.com/v1/projects/{PROJECT_ID}/databases/(default)/documents/{COLLECTION_ID}',
json=data,
headers={
'Content-Type': 'application/json',
'key': C.FIRESTORE_API_KEY
},
)
So, how's this different from what I'm doing with MicroPython?
To Reproduce
Steps to reproduce the behavior:
- Connect device to WIFI access
- Make a
fetch(...) request to Cloud Firestore
- Get SSL Self Signed Cert error
- Cry
Expected behavior
Be able to successfully make a request to Cloud Firestore.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Console Output:
VM> connecting to tls://firestore.googleapis.com:443
VM> socket tls://firestore.googleapis.com:443 open undefined
VM> req: POST /v1/projects/[PROJECT_ID]/databases/(default)/documents/sensors HTTP/1.1
VM> content-type: application/json
VM> key: [API_KEY]
VM> user-agent: DeviceScript fetch()
VM> accept: */*
VM> host: firestore.googleapis.com
VM> connection: close
VM> content-length: 2
VM>
VM> socket tls://firestore.googleapis.com:443 error tls://firestore.googleapis.com:443: self-signed certificate
Describe the bug
From a ESP32 device, I want to post some data to a Cloud Firestore, thus I'm using
fetch(...)function to achieve that.The store is currently unprotected for the moment, so any data can be posted without much overhead.
Thing is, I get a
socket tls://firestore.googleapis.com:443 error tls://firestore.googleapis.com:443: self-signed certificate.This is my code:
NOTE: I tried exactly the same with MicroPython, and works like a charm.
Here is my python code:
So, how's this different from what I'm doing with MicroPython?
To Reproduce
Steps to reproduce the behavior:
fetch(...)request to Cloud FirestoreExpected behavior
Be able to successfully make a request to Cloud Firestore.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Console Output: