Comments (10)
I'm not sure this is covered by this documentation, did you ask in Discord? https://github.com/nightscout/cgm-remote-monitor/issues/new/choose
from nightscout.github.io.
Howdy @dcallagh. I think you would benefit from looking at curl
and a tool like json
to accomplish something like the following:
cat <<EOT | json | curl --data-binary @- -H "Content-Type: application/json" -H "API_SECRET: $hashed_secret" https:///api/1/treatments.json
[{"eventType":"","created_at":"2021-04-10T15:28:00Z","carbs":27,"insulin":3.9}]"
EOT
Note that the api secret has been hashed using something like echo -n mylongplainsecret | sha1sum - | cut -d ' ' -f 1
. Also, there are subtle differences between -d
or --data
and --data-binary
: --data-binary
without any extra urlencoding is probably what you want.
from nightscout.github.io.
Hi Ben,
Thanks for the help, as I suspected the CURL on nightscout swagger is wrong. I have had another look using the nightscout 'ADD treatment' panel, and the error is the name of the auth token: Lowercase "api-secret" is correct so the swagger page should be corrected. I had previously looked at the ADD panel but was focussed on the sha1 value and did not notice the api token was a different name.
Result from using your suggested curl command slightly amended to include Json embedded, but still with the upper case API_SECRET gave the same error:
$ hashed_scret=echo -n <passkey> | sha1sum - | cut -d ' ' -f 1
$ curl --data-binary '[{"eventType":"","created_at":"2021-04-10T15:28:00Z","carbs":27,"insulin":3.9}]' -H "Content-Type: application/json" -H "API_SECRET: $hashed_scret" -X POST https://.herokuapp.com/api/v1/treatments.json
{"status":401,"message":"Unauthorized","description":"Invalid/Missing"}
from nightscout.github.io.
Hey @dcallagh ,
I think that I have found something for that matter. Here it says that you need to put API-SECRET instead of API_SECRET to the header and the secret itself should be SHA1 hashed
Hope that helps!
from nightscout.github.io.
I must say that this did not seem to work with latest version, but in any case if someone gets into here:
REST_ENDPOINT=https://snirdev.hopto.org/api/v1/entries.json?token=try-0da467168cf4xxxx
curl -m 30 -s -X POST --data-binary @${ENTRIES} -H "content-type: application/json" ${REST_ENDPOINT}
This works, with the new security model where the token has write permissions.
from nightscout.github.io.
@dcallagh,
Did you manage to resolve the problem? I'm going through the same situation.
from nightscout.github.io.
from nightscout.github.io.
from nightscout.github.io.
@dcallagh, I tried with the code below, but it's not working. :/
#############
myHash='d018020ba8f49a010afdbabf7e8be89441085750'
header1 = {'api-secret': myHash}
data = {
"carbs": 10
}
resposta = requests.post('http://192.168.0.1:17580/entries', headers=header1, json=data)
print(resposta.status_code)
print (resposta.text)
from nightscout.github.io.
from nightscout.github.io.
Related Issues (20)
- OBSCURED and OBSCURE_DEVICE_PROVENANCE variables HOT 1
- Dexcom bridge doesn't work as clarity account is stored on clarity.dexcom.jp
- The Nightscout webpage seems completely broken for me HOT 2
- update stack for heroku app HOT 5
- flyctl is deploying 2 machines for HA and it breaks Nightscout websocket HOT 1
- Ich HOT 1
- Request update in /source/docs/vendors/heroku/migrate.md - the railway section should note that it is no longer free HOT 1
- Fly.io secrets vs fly.toml HOT 1
- Add Caddy as remote proxy in Docker method HOT 7
- Nightscout APN issue in Northflank build HOT 2
- Minor Azure Page: REMOVE the obsolete Video HOT 3
- got billed 5.24 usd for Nightscout usage HOT 6
- Missed one Fly.io
- Fly.io will charge for dedicated IPv4 in January 1st HOT 6
- Fly.io removed the web terminal HOT 1
- Blue background on web HOT 6
- Change Variables on fly HOT 1
- Error in documentation uploader/setup.md: change `CONNECT_SHARE_SERVER` to `CONNECT_SHARE_REGION` HOT 1
- Fly.io migration wizard is removed HOT 1
- Nightscout update with Fly.io is missing HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nightscout.github.io.