Skip to content

Commit

Permalink
Merge branch 'tiddlywiki-com'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jermolene committed Mar 27, 2024
2 parents 801ed0e + d37d659 commit 90a6f31
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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=<<url>>
method="GET"
header-Authorization={{{ [<username>addsuffix[:]addsuffix<password>encodebase64[]addprefix[Basic ]] }}}
oncompletion=<<completion-get-json>>
/>
\end get-tiddler-list-from-tiddlywiki-server

<$button>
<<get-tiddler-list-from-tiddlywiki-server url:"http://127.0.0.1:8080" username:"Joe" password:"Bloggs">>
Download
</$button>
```

Original file line number Diff line number Diff line change
Expand Up @@ -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]]

0 comments on commit 90a6f31

Please sign in to comment.