Node-red-contrib-ocpp - enable basic auth

I've recently had a good conversation with @bnystrom who is the author of node-red-contrib-ocpp regarding providing basic auth for the node's server websocket, and wanted to share it here, in case it's needed now or in the future.

Enabling auth
Basic auth can be enabled by injecting a command into a CS Request JSON node, which is linked to your CS Server node.
Simply, set an inject node to JSON & use the code below.

{
    "command": "LOCAL_SET_ALL_AUTH_EVSES",
    "data": {
        "BS542T766": "your-charger-password"
    }
}

What if you don't know your charger's auth password?
You will need to set up an environment variable named "DEBUG" with "anl:ocpp:*"
Set your node-red's logging setting to DEBUG, and restart node-RED.
Then if you run node-red-log you should start to see ocpp data appearing in the log.
To find the password, restart the NR server (Restart Flows will do) and you should see something similar to this below,

2025-06-21T13:20:17.886Z anl:ocpp:cs:server Websocket connection to : BS542T758
2025-06-21T13:20:17.887Z anl:ocpp:cs:server Try to Auth: BS542T766 = BS542T758 with p/w 12349876
2025-06-21T13:20:17.887Z anl:ocpp:cs:server Authorized

As you can see, the charger's password is 12349876, which is what you should include in the above command.

How to disable Basic Auth
Simply follow Enabling Auth above, but inject the below instead, which removes the password, therefore auth.

{
    "command": "LOCAL_SET_ALL_AUTH_EVSES",
    "data": {
        "BS542T766": ""
    }
}
1 Like