Jump to content

Acessing the API fails with curl - what am I doing wrong?


hlinden

Recommended Posts

Posted · Acessing the API fails with curl - what am I doing wrong?

When I access /api/v1/auth/verify using Firefox, that works fine.

When I create a curl request from that using the Firefox debugger that works fine:

 

[me@machine]$ curl "http://xxx.xxx.xxx.xxx/api/v1/auth/verify" -H "Host: xxx.xxx.xxx.xxx" -H "User-Agent: Mozilla/5.0 (Windows NT 10.) Gecko/20100101 Firefox/45.0" -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" -H "Accept-Language: de,en-US;q=0.7,en;q=0.3" --compressed -H "Authorization: Digest username=""6384f43f0e8aef0e024949b01fe67ba3"", realm=""Jedi-API"", nonce=""dcf0ed0acc248b6918bd25bef863996f"", uri=""/api/v1/auth/verify"", response=""e39ef5c9445ee93a237244dbf2e50aa8"", qop=auth, nc=00000007, cnonce=""87d281d69398db60""" -H "Connection: keep-alive" -H "Cache-Control: max-age=0"{"message": "ok"}

 

When I try to use curl with the same credentials and basic auth it fails:

 

[me@machine ~]$ curl -vv -u 6384f43f0e8aef0e024949b01fe67ba3:6453bdd1aa2ad0c8f2fcb8c8ef2fe7b9b550c654abbbbe54d3455bccc2bee83f http://xxx.xxx.xxx.xxx/api/v1/auth/verify*   Trying xxx.xxx.xxx.xxx...* TCP_NODELAY set* Connected to xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx) port 80 (#0)* Server auth using Basic with user '6384f43f0e8aef0e024949b01fe67ba3'> GET /api/v1/auth/verify HTTP/1.1> Host: xxx.xxx.xxx.xxx> Authorization: Basic NjM4NGY0M2YwZThhZWYwZTAyNDk0OWIwMWZlNjdiYTM6NjQ1M2JkZDFhYTJhZDBjOGYyZmNiOGM4ZWYyZmU3YjliNTUwYzY1NGFiYmJiZTU0ZDM0NTViY2NjMmJlZTgzZg==> User-Agent: curl/7.51.0> Accept: */*>* HTTP 1.0, assume close after body< HTTP/1.0 401 UNAUTHORIZED< Content-Type: application/json< Content-Length: 38< Cache-Control: no-cache, no-store, must-revalidate< Pragma: no-cache< Expires: 0< WWW-Authenticate: Digest qop=auth, realm="Jedi-API", nonce="27495c91bef5eaf2c338c2dda9d95a5c"< Server: Werkzeug/0.9.6 Python/3.4.2< Date: Tue, 21 Mar 2017 12:51:59 GMT<* Curl_http_done: called premature == 0* Closing connection 0{"message": "Authorization required."}

 

What am I doing wrong here?

  • Link to post
    Share on other sites

    Posted · Acessing the API fails with curl - what am I doing wrong?

    I can see that Firefox uses double double quotes for some values. Maybe it is a formatting issue on the command line. You could put the parameters in a text file and have curl read from that file.

  • 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

      • UltiMaker Cura 5.7 stable released
        Cura 5.7 is here and it brings a handy new workflow improvement when using Thingiverse and Cura together, as well as additional capabilities for Method series printers, and a powerful way of sharing print settings using new printer-agnostic project files! Read on to find out about all of these improvements and more. 
         
          • Like
        • 18 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...