From 61b06eff065da03b5e8e8205dbeaf6010e612404 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 6 Feb 2023 20:26:43 +0100 Subject: [PATCH] providers/proxy: better log outpost token errors Signed-off-by: Jens Langhammer --- internal/outpost/proxyv2/application/auth_basic.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/outpost/proxyv2/application/auth_basic.go b/internal/outpost/proxyv2/application/auth_basic.go index 2cf2a5027..4e9177be8 100644 --- a/internal/outpost/proxyv2/application/auth_basic.go +++ b/internal/outpost/proxyv2/application/auth_basic.go @@ -3,6 +3,7 @@ package application import ( "context" "encoding/json" + "io" "net/http" "net/url" "strings" @@ -29,7 +30,11 @@ func (a *Application) attemptBasicAuth(username, password string) *Claims { req.Header.Set("Content-Type", "application/x-www-form-urlencoded") res, err := a.httpClient.Do(req) if err != nil || res.StatusCode > 200 { - a.log.WithError(err).Warning("failed to send token request") + b, err := io.ReadAll(res.Body) + if err != nil { + b = []byte(err.Error()) + } + a.log.WithError(err).WithField("body", string(b)).Warning("failed to send token request") return nil } var token TokenResponse