Struggling to authenticate to API in Node-RED but works in Postman

Would appreciate a little help as a Node-RED noob please.

I'm trying to authenticate to an API within Node-RED and the developers have used either HTTP Basic Authorization or JSON POST.

So my first step was to test the HTTP Basic Authorization in Postman:

I used the POST method
and under Auth selected "Basic Auth"
and then entered my Username and Password

When I click send the Body comes back with an array of objects and the one of interest to me is the token which is a string that I will be able to use to authenticate subsequent queries to the API presumably.

Two questions:

  1. How can I replicate this Basic Auth in Node-RED and return the token? And would it be better to JSON POST instead and if so how to go about doing that?
  2. How can I use the token in my subsequent requests to the API?

There is alot of information online about public API's when you can use a key. Would appreciate any words from the wise.

A basic auth request is already built-in

Did you try this ?

Thank you for your reply. Apologies for the delay in a return post. I ended up abandoning the API integration and using an MQTT broker which I set up as an intermediary between the modbus gateway that I needed to communicate with and the end points. MQTT works very well. Still struggling with authentication on the MosQuiTTo broker so I think I've for now turned off the passwords to test comms and will re-enable them when I move this system into production.

I do need to learn the API method but I'm finding the vendors documentation to be quite weak. Wasting a lot of time trying to improve it and eventually said let me try another method

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.