Authentication
Send a bearer token in the Authorization header of each call:
Authorization: Bearer <token>
Give each system only the access that it needs. Give a control token only to a system that must control equipment.
| Web app token | Edge Server token | Edge Server control token | |
|---|---|---|---|
| Read API: sensors, thresholds, account | Yes | No (401) | No (401) |
| Read API: outlets, Controllers | No (401) | Yes | Yes |
| Write API | No (401) | No (403) | Yes |
| Where to make it | The Growbud web app | The Edge Server | The Edge Server |
Web app tokens
- Make an account in the Growbud mobile app.
- Sign in at growbud.app.
- Turn on API access in your profile settings. If API access is off, each call gets 403.
- Make a token. Set it to expire after 1 to 365 days (the default is 30), or never.
You can have 10 active tokens. You can revoke a token at any time. A web app token reads all the sensors on your account. It cannot change anything.
Edge Server tokens
Make these tokens on the Edge Server. An administrator runs these commands on the Edge Server computer, in the install folder. The user must be a user of that Edge Server.
docker compose exec outlets node /app/edge-outlets.mjs token create \
--email integrator@example.com --name "BMS" --days 365 --scope control
docker compose exec outlets node /app/edge-outlets.mjs token list
docker compose exec outlets node /app/edge-outlets.mjs token revoke <id>
The command shows the token one time only. Copy it immediately. --days is 1 to 3650 (the default is 365). Without --scope control, the token can only read outlets and Controllers.
- An Edge Server token works only on the Edge Server that made it.
- The token acts as its user. It gets the outlets and Controllers of the user's organization, and the outlets that the user owns. Other devices give 404.
- All members can switch outlets and Controller outputs.
- A revoked or expired token gets 401. The Edge Server records each Write API call with its token.
The Edge Server is on port 8443 on your network, for example https://192.168.1.27:8443. If your client does not trust its certificate, use curl with -k.