No activity today, make something!
tiddlyweb Authenticating with curl

20160313160656 cdent  

If you use curl to access TiddlyWeb, and are working with tiddlers behind a restrictive policy you may need to authenticate.

Using HTTP Basic Authentication

curl -X GET -H 'Content-Type: application/vnd.tiddlyweb+json' \
    -u <username>:<password> \
    http://localhost:8080/recipes/confidential

Using Cookies

If you log in with a username and password and then want to use a cookie as the auth token, you can do the following:

First use curl to post username and password to the cookie_form and store a cookie for it locally:

curl --cookie-jar cookies.txt \
   -d "user=<username>&password=<password>&submit=submit \
   <yourwebsite.com>/challenge/cookie_form

Pass the created cookie to subsequent post to upload tiddlers

curl --cookie cookies.txt -X PUT -H 'Content-Type: text/plain' \
   --data-binary @<filename \
   <yourwebsite.com>/bags/default/tiddlers/monkey

source

If you prefer to use the cookie directly, rather than creating a cookie jar, you may do the following:

  • Log in a browser.
  • Visit the cookies for the current domain and get the value of the tiddlyweb_user cookie.
  • Make your curl request, but add a Cookie header containing that value as a tiddlyweb_user cookie:
curl -H 'Cookie: tiddlyweb_user=someuser:xxxxxxxxxxxxxxxxxxx' \
    -X PUT -H 'Contenet-Type: text/plain'  \
    --data-binary@<filename \
    <yourwebsite.com/bags/default/tiddlers/monkey