HTTP request - digest auth?

Hi everyone,

first post in this forum for me, so don't be too harsh :slight_smile:

I had a flow running which sent me a picture of my webcam to a telegram chanel once a motion detector sensed motion. This was working fine until the webcam died and I had to replace it with a new model.
Now obviously the HTTP request node does not work anymore - I suspect it's due to the new camera requiring digest auth instead of basic?!

The new cam (Wansview W2) can be accessed via http://user:pass@192.168.178.xx/mjpeg/snap.cgi?chn=1
this works perfectly fine in a browser.
Trying to run this command via the HTTP request node fails, no matter if I provide user:pass within the url or via the basic auth boxes.
Trying to nail the issue down I tried it with curl:
curl http://user:pass@192.168.178.xx/mjpeg/snap.cgi?chn=1 results in a 401 unauthorized
curl http://user:pass@192.168.178.xx/mjpeg/snap.cgi?chn=1 --digest works fine

Now the question is: How can I get this running in Node-Red? :wink:

Any help is apprecitated.

Thanks

Would this do the trick? It supports digest authentication.

As far as I understood the httpauth node it only supports digest for incoming http requests TO Node-Red. What I was looking for is outgoing requests FROM Node-Red.

I have solved the issue by running the curl in an exec node and storing the image temporarily:

[
    {
        "id": "9bc395e2.696468",
        "type": "exec",
        "z": "77b6ee06.c70d8",
        "command": "curl http://user:pass@IP/mjpeg/snap.cgi?chn=1 --digest -o /tmp/cam.jpg",
        "addpay": false,
        "append": "",
        "useSpawn": "false",
        "timer": "",
        "oldrc": false,
        "name": "CURL",
        "x": 390,
        "y": 200,
        "wires": [
            [],
            [
                "6510e24d.78b2fc"
            ],
            []
        ]
    },
    {
        "id": "6510e24d.78b2fc",
        "type": "delay",
        "z": "77b6ee06.c70d8",
        "name": "",
        "pauseType": "delay",
        "timeout": "1",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "x": 520,
        "y": 200,
        "wires": [
            [
                "9a5d8fc6.92ea88"
            ]
        ]
    },
    {
        "id": "9a5d8fc6.92ea88",
        "type": "file in",
        "z": "77b6ee06.c70d8",
        "name": "",
        "filename": "/tmp/cam.jpg",
        "format": "",
        "sendError": true,
        "x": 690,
        "y": 200,
        "wires": [
            [
                "5ab9f6c4.aa642"
            ]
        ]
    },
    {
        "id": "5ab9f6c4.aa642",
        "type": "change",
        "z": "77b6ee06.c70d8",
        "name": "Set Headers",
        "rules": [
            {
                "t": "set",
                "p": "headers",
                "pt": "msg",
                "to": "{}",
                "tot": "json"
            },
            {
                "t": "set",
                "p": "headers.content-type",
                "pt": "msg",
                "to": "image/jpg",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 870,
        "y": 200,
        "wires": [
            [
                "a8a65b8b.e2cf7"
            ]
        ]
    }
]
1 Like