
Is there an existing function to create a basic auth header given a username & password? I think it’s just a matter of joining the username & password with a colon, and base64 encoding that, but if there’s an existing function I’d use that.

I suppose this will do: (define (create-basic-auth-header username password)
(string-append
"Authorization: Basic "
(bytes->string/utf-8
(base64-encode
(string->bytes/utf-8
(string-append username ":" password))
""))))

That’s pretty close to what I have in my bespoke unpublished http client package: (define (make-encoded-credential username password)
(string-append
"Basic "
(bytes->string/utf-8
(bytes-trim-right-crlf
(base64-encode
(string->bytes/utf-8 (string-append username ":" password)))))))

base64-encode
adds a crlf to the end of the bytes so I trim that off.

If you pass a second arg of "", it won’t add the crlf

Nice!