I have an esp32 board connected to a SIM800L gsm/gprs module. I'm using TinyGSM library for this project. Somehow I cannot get my setup to publish data succesfully through an http bridge to the Google cloud. Previously I ran the examples shown on the documentation on how to do this using curl, and I was succesful.
curl -X POST -H 'authorization: Bearer JWT' -H 'content-type: application/json' --data '{"state": {"binary_data": "DATA"}}' -H 'cache-control: no-cache' 'https://cloudiotdevice.googleapis.com/v1/projects/{project-id}/locations/{cloud-region}/registries/{registry-id}/devices/{deviceid}:setState'
When I generate the supposed same request with TinyGSM and the esp32, I always get the same http response from the google server:
"error": { "code": 403, "message": "The caller does not have permission", "status": "PERMISSION_DENIED" }
At first I thought it had something to do with an incorrect JWT, but when changed deliberately to a wrong one, the error message changes to:
"error": { "code": 401, "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.", "status": "UNAUTHENTICATED" }
So I guess I can rule out a possible invalid JWT
I suspect there might be something wrong with my project configurations, but if that's the case I don't understand why it always works with curl but never with the esp32.