From 63fecc70c92bee4011118b3a5bffcbfceb7bbe1d Mon Sep 17 00:00:00 2001 From: Repo Assist Date: Thu, 26 Feb 2026 15:28:38 +0000 Subject: [PATCH 1/2] docs: add HTTP Authentication section to Http.fsx Document Basic Auth, Bearer token, and Windows/NTLM auth patterns using the existing HttpRequestHeaders helpers and customizeHttpRequest. Closes #158 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/library/Http.fsx | 65 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/docs/library/Http.fsx b/docs/library/Http.fsx index 0bfa2c831..48c5e57f2 100644 --- a/docs/library/Http.fsx +++ b/docs/library/Http.fsx @@ -241,6 +241,71 @@ match Http.Request(logoUrl).Body with | Text text -> printfn "Got text content: %s" text | Binary bytes -> printfn "Got %d bytes of binary content" bytes.Length +(** +## HTTP Authentication + +FSharp.Data provides built-in helpers in `cref:T:FSharp.Data.HttpRequestHeaders` for the most common authentication schemes. + +### Basic authentication + +Use `cref:M:FSharp.Data.HttpRequestHeaders.BasicAuth` to add an `Authorization: Basic …` header. +The helper encodes the credentials as UTF-8 before base64-encoding them: +*) + +(*** do-not-eval ***) + +Http.RequestString( + "https://api.example.com/data", + headers = [ HttpRequestHeaders.BasicAuth "myUsername" "myPassword" ] +) + +(** +### Bearer / token authentication + +Use `cref:M:FSharp.Data.HttpRequestHeaders.Authorization` to send any other `Authorization` header value, +such as a Bearer token used by OAuth 2.0 or personal-access-token APIs: +*) + +(*** do-not-eval ***) + +let token = "" + +Http.RequestString( + "https://api.github.com/user", + headers = + [ HttpRequestHeaders.Authorization(sprintf "Bearer %s" token) + HttpRequestHeaders.UserAgent "MyApp" ] +) + +(** +### Windows / NTLM integrated authentication + +For services that require Windows Integrated Authentication (NTLM or Negotiate), use the +`customizeHttpRequest` parameter to set the credentials on the underlying `HttpWebRequest`: +*) + +(*** do-not-eval ***) + +open System.Net + +// Use the current Windows user's credentials +Http.RequestString( + "https://intranet.example.com/api/data", + customizeHttpRequest = + fun req -> + req.UseDefaultCredentials <- true + req +) + +// Or supply explicit credentials +Http.RequestString( + "https://intranet.example.com/api/data", + customizeHttpRequest = + fun req -> + req.Credentials <- NetworkCredential("username", "password", "DOMAIN") + req +) + (** ## Customizing the HTTP request From 851f45b71e7970233989cb085d53935325ff2d8d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 26 Feb 2026 15:31:32 +0000 Subject: [PATCH 2/2] ci: trigger CI checks