From 81eaf56c012dec4f64f223f4c41811e32ea2ce53 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Wed, 18 Nov 2020 12:47:32 -1000 Subject: [PATCH] readme: document basic auth usage Fixes: https://github.com/feross/simple-get/issues/57 --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 0fecf371..359cb47d 100644 --- a/README.md +++ b/README.md @@ -254,6 +254,20 @@ const opts = { get(opts, function (err, res) {}) ``` +### Basic Auth + +```js +const user = 'someuser' +const pass = 'pa$$word' +const encodedAuth = Buffer.from(`${user}:${pass}`).toString('base64') + +get('http://example.com', { + headers: { + authorization: `Basic ${encodedAuth}` + } +}) +``` + ### OAuth You can use the [`oauth-1.0a`](https://github.com/ddo/oauth-1.0a) module to create