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)