From be1d473950195da5548f46801967e08fdc6d8a29 Mon Sep 17 00:00:00 2001 From: "David J. Allen" Date: Fri, 15 Mar 2024 17:43:53 -0600 Subject: [PATCH] Added access token to collect header if supplied --- internal/collect.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/collect.go b/internal/collect.go index b00ee63..5686066 100644 --- a/internal/collect.go +++ b/internal/collect.go @@ -50,6 +50,7 @@ type QueryParams struct { IpmitoolPath string OutputPath string ForceUpdate bool + AccessToken string } func NewClient(l *log.Logger, q *QueryParams) (*bmclib.Client, error) { @@ -209,6 +210,11 @@ func CollectAll(probeStates *[]ScannedResult, l *log.Logger, q *QueryParams) err headers := make(map[string]string) headers["Content-Type"] = "application/json" + // use access token in authorization header if we have it + if q.AccessToken != "" { + headers["Authorization"] = "Bearer " + q.AccessToken + } + body, err := json.MarshalIndent(data, "", " ") if err != nil { l.Log.Errorf("could not marshal JSON: %v", err)