From e02cafb938be8c96d59d0fbe11310f6cc8460ffb Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Wed, 27 Mar 2024 08:35:56 +0000 Subject: [PATCH 1/2] Add docs about using Basic Authentication in HTTP requests --- ...p-request Example Basic Authentication.tid | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-http-request Example Basic Authentication.tid diff --git a/editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-http-request Example Basic Authentication.tid b/editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-http-request Example Basic Authentication.tid new file mode 100644 index 000000000..e16428d4a --- /dev/null +++ b/editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-http-request Example Basic Authentication.tid @@ -0,0 +1,34 @@ +title: WidgetMessage: tm-http-request Example - Basic Authentication +tags: $:/tags/Global + + +!! HTTP Basic Authentication + +[[HTTP Basic Authentication|https://en.wikipedia.org/wiki/Basic_access_authentication]] is a simple scheme for HTTP clients pass a username and password to an HTTP server. + +The credentials are passed via the "Authorization" header as the string "Basic " (note the space) followed by the base64-encoded username and password joined with a colon. + +Here is a simple, illustrative example: + +``` +\procedure get-tiddler-list-from-tiddlywiki-server(url,username,password) + \procedure completion-get-json() + \import [subfilter{$:/core/config/GlobalImportFilter}] + <$action-log msg="In completion-get-json"/> + <$action-log/> + \end completion-get-json + <$action-sendmessage + $message="tm-http-request" + url=<> + method="GET" + header-Authorization={{{ [addsuffix[:]addsuffixencodebase64[]addprefix[Basic ]] }}} + oncompletion=<> + /> +\end get-tiddler-list-from-tiddlywiki-server + +<$button> +<> +Download + +``` + From d37d6595b54e7816e0d4256129f92ea72a30b95c Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Wed, 27 Mar 2024 10:09:46 +0000 Subject: [PATCH 2/2] Docs: Add link to Basic Auth example --- .../tw5.com/tiddlers/messages/WidgetMessage_ tm-http-request.tid | 1 + 1 file changed, 1 insertion(+) diff --git a/editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-http-request.tid b/editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-http-request.tid index e370ad72c..d2dd6eed7 100644 --- a/editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-http-request.tid +++ b/editions/tw5.com/tiddlers/messages/WidgetMessage_ tm-http-request.tid @@ -51,3 +51,4 @@ Note that the state tiddler $:/state/http-requests contains a number representin * [[Zotero's|https://www.zotero.org/]] API for retrieving reference items: [[WidgetMessage: tm-http-request Example - Zotero]] * [[Random Dog's|https://random.dog/]] API for retrieving random pictures of dogs showing how to retrieve binary data: [[WidgetMessage: tm-http-request Example - Random Dog]] +* Example of using HTTP Basic Authentication: [[WidgetMessage: tm-http-request Example - Basic Authentication]]