API OAuth 1.0 using http request node

Hello everyone. I am new here, so I may have some stupid questions.
I have an API from woocommerce. Since the website is using https , the basic auth from the node(http request) is not working. This is the error:
{“code”:”woocommerce_rest_cannot_view”,”message”:”Sorry, you cannot list resources.”,”data”:{“status”:401}}

After making some digging, Looks like in this setup I need to use OAuth 1.0. I made some tests using postman and this is correct.
So , my question is how can I use OAuth 1.0 to GET items in node-red?
Thanks

Oooh, good question... I'm currently working on a specialised node that uses OAuth 1.0a inside. Because of other needs I'm making it a contribution node rather than doing it in the flow. If you give me a bit I'll see if it can be done directly with the http request node, but chances are that you might either need to include an npm library through the globalFunctionContext (I'll explain in a bit), or rely on a contribution node that does this.

Okay, I took a quick look. Since I've implemented OAuth 1.0a a couple times from scratch in different programming languages, I know the details you don't want to be aware off if you prefer staying sane :grimacing:
While it's not directly supported by the HTTP Request node, you can do it yourself using the Authorization header, but I would not advise that. I've just seen this node in the flows library, node-red-contrib-oauth1a: https://flows.nodered.org/node/node-red-contrib-oauth1a
I've never used it before, but I took a quick scan through the code, and it looks to be decent. I'm using a different oauth library in the back myself, but this one I've seen before, just not my preferred option if I'm working on nodes myself. I think it might work for your needs, but if you need further help setting it up, just type @afelix in a post and I'll see if I can help you any further. It's a generic node, but all the documentation and examples refer to twitter, so that can be confusing.

1 Like

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