Jump to content

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.9 stable released!
        Here comes Cura 5.9 and in this stable release we have lots of material and printer profiles for UltiMaker printers, including the newly released Sketch Sprint. Additionally, scarf seams have been introduced alongside even more print settings and improvements.  Check out the rest of this article to find out the details on all of that and more
          • Like
        • 5 replies
      • Introducing the UltiMaker Factor 4
        We are happy to announce the next evolution in the UltiMaker 3D printer lineup: the UltiMaker Factor 4 industrial-grade 3D printer, designed to take manufacturing to new levels of efficiency and reliability. Factor 4 is an end-to-end 3D printing solution for light industrial applications
          • Heart
          • Thanks
          • Like
        • 7 replies
    ×
    ×
    • Create New...