petkov / http_to_mqtt

HTTP to MQTT bridge
89 stars 64 forks source link

quest is not authorized. #10

Open Micky79NRW opened 5 years ago

Micky79NRW commented 5 years ago

Hi,

I installed http_to_mqtt in a docker container with this image: https://github.com/MiGoller/docker-http-mqtt-bridge

Startup looks fine: 2019-07-21T16:07:44: PM2 log: Launching in no daemon mode 2019-07-21T16:07:44: PM2 log: App [HTTP-To-MQTT-Bridge:0] starting in -fork mode- 2019-07-21T16:07:44: PM2 log: App [HTTP-To-MQTT-Bridge:0] online Node app is running on port 5000

but if I post a message I get this error:

Received request [/post] from [::ffff:192.168.xxx.xxx]. quest is not authorized.

Do you have any idea what this problem is?

Best regards from Germany Michael

robdejonge commented 4 years ago

When you send the request, make sure you pass along the key.

For example, curl -H "Content-Type: application/json" "http://localhost:5000/post" -d '{"topic" : "MyTopic", "message" : "Hello World", "key" : "THE_AUTH_KEY_YOU_SET_WHEN_YOU_LAUNCHED_THE_CONTAINER"}'

innesleroux commented 3 years ago

Hi

I get it to work using above example and curl no problem. How would I use it in a browser by just typing the http?

Example:

http://192.168.1.65:5000/post?topic=cmnd/lamp/power&message=1&key=secretkey123

but all i get is:

Cannot GET /post?topic=cmnd/lamp/power&message=1&key=secretkey123

Please help!

Thanks

petkov commented 3 years ago

This is a HTTP POST request, you can't do that by typing this URL in the browser.

petkov commented 3 years ago

Try changing line 110 in index.js to app.get