Jump to content

How to auth with node-red against UM3 REST API


Aim23

Recommended Posts

Posted · How to auth with node-red against UM3 REST API

Hey everybody,

 

I am desperate. Here in short what I want to do:

Using node-red as platform for crosslinking different IOT devices with different services. Like a MQTT Broker, Telegram and other.

What I'm using right now is: RedBot for asking my UM3+ what is going on with the current print job, how the print looks like (grabbing an image from the integrated camera and sending it to the chat via the Telegram bot). 

What I want to do now is, if I see the printjob is failing right now after image checking, to stop the print via the bot. For this action, node-red needs to be authenticated in the REST API. I have an id and key generated which is valid and ready for use. 

So how do I do this, any ideas or suggestions? Would be very helpfull. 

 

Thanks ;)

Marcel

Curl
curl -X GET --header 'Accept: application/json' 'http://um3ip/api/v1/auth/check/fad462df155f52ceb0e6ce8ed64845ed'

Request URL
http://um3ip/api/v1/auth/check/fad462df155f52ceb0e6ce8ed64845ed

Response Body
{
  "message": "authorized"
}

 

[{"id":"1300e776.abe2f1","type":"change","z":"5674bd4d.d67064","name":"Set Headers","rules":[{"t":"set","p":"headers","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"headers.content-type","pt":"msg","to":"application/json","tot":"str"},{"t":"set","p":"headers.Authorization","pt":"msg","to":"Digest username=\"fad462df155f52ceb0e6ce8ed64845ed\", password=\"2789fb63914e0fac010b2489e4358becdd22886997151e093894e518a198a264\", uri=\"/api/v1/auth/verify\", realm=\"Jedi-API\", qop=auth","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":1297,"wires":[["d710857b.bc85f","bf1c1cce.74dc98"]]},{"id":"d710857b.bc85f","type":"http request","z":"5674bd4d.d67064","name":"","method":"GET","ret":"obj","url":"http://um3ip/api/v1/auth/verify","tls":"","x":568,"y":1296,"wires":[["caad6ed4.e755a"]]},{"id":"bf1c1cce.74dc98","type":"debug","z":"5674bd4d.d67064","name":"","active":true,"console":"false","complete":"true","x":633,"y":1397,"wires":[]},{"id":"f0c9e7a5.d0cd68","type":"inject","z":"5674bd4d.d67064","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":197,"y":1249,"wires":[["1300e776.abe2f1"]]},{"id":"caad6ed4.e755a","type":"debug","z":"5674bd4d.d67064","name":"","active":true,"console":"false","complete":"true","x":737,"y":1259,"wires":[]}]

 

  • Link to post
    Share on other sites

    Posted · How to auth with node-red against UM3 REST API

    I have no experience with node-red. So I cannot help you on that part. I did post a python example in my topic about the API, that might help?

     

    But the UM3 API requires HTTP Digest with "auth" quality-of-protection. (The Digest standard makes this optional, but that completely ruins the security, and thus we made it required) most libraries handle this seamlessly.

     

    Part of the "auth" quiality-of-protection are one-time-use tokens, called "nonce". Which I'm not sure if node-red is handling for you or not.

  • Link to post
    Share on other sites

    Posted · How to auth with node-red against UM3 REST API

    You might also try the Cura Connect API (on newer firmware versions) which currently has not authentication. Docs are available on http://{PRINTER_IP}/cluster-api/v1/.

  • Link to post
    Share on other sites

    Posted · How to auth with node-red against UM3 REST API

    There's a little more information right here (images seem to be missing, but everything should be clear):

     

    I would first try to get the /verify call working with cURL. I believe it should be as simple as adding a "--digest" parameter:

    https://stackoverflow.com/questions/9435678/curl-digest-command

     

    Next, you need to get it into Node-red. From what I know about this (= not much), it's based on node, so JavaScript. It looks like some of the libraries don't completely support digest authentication, so if it doesn't work, probably best to try another library. This is just the first thing that comes up:

    https://stackoverflow.com/questions/17110783/how-to-do-request-http-digest-auth-with-node-js

     

     

  • Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    • Our picks

      • Introducing Universal Cura Projects in the UltiMaker Cura 5.7 beta
        Strap in for the first Cura release of 2024! This 5.7 beta release brings new material profiles as well as cloud printing for Method series printers, and introduces a powerful new way of sharing print settings using printer-agnostic project files! Also, if you want to download the cute dinosaur card holder featured below, it was specially designed for this release and can be found on Thingiverse! 
          • Like
        • 10 replies
      • S-Line Firmware 8.3.0 was released Nov. 20th on the "Latest" firmware branch.
        (Sorry, was out of office when this released)

        This update is for...
        All UltiMaker S series  
        New features
         
        Temperature status. During print preparation, the temperatures of the print cores and build plate will be shown on the display. This gives a better indication of the progress and remaining wait time. Save log files in paused state. It is now possible to save the printer's log files to USB if the currently active print job is paused. Previously, the Dump logs to USB option was only enabled if the printer was in idle state. Confirm print removal via Digital Factory. If the printer is connected to the Digital Factory, it is now possible to confirm the removal of a previous print job via the Digital Factory interface. This is useful in situations where the build plate is clear, but the operator forgot to select Confirm removal on the printer’s display. Visit this page for more information about this feature.
          • Like
        • 0 replies
    ×
    ×
    • Create New...