Jump to content
hlinden

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

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?

Share this post


Link to post
Share on other sites
Posted · Acessing the API fails with curl - what am I doing wrong?

Could a mod please move this post to the appropriate subforum?

Share this post


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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Our picks

    • Ultimaker Cura 4.0 | Stable available!
      Ultimaker Cura 4.0 is mainly focused on the improved user interface and cloud integration.
      As always, we want to collect your user feedback for this release. If there are any improvements you can think of, feel free to mention it here and help us to shape the next release.
      • 96 replies
×
×
  • Create New...

Important Information

Welcome to the Ultimaker Community of 3D printing experts. Visit the following links to read more about our Terms of Use or our Privacy Policy. Thank you!