diff --git a/client/token.go b/client/token.go index 918afb4..2bf650e 100755 --- a/client/token.go +++ b/client/token.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "gitea.siteworxpro.com/golang-packages/email-api-client/redis" + "io" "net/http" "time" ) @@ -52,8 +53,11 @@ func getToken(configuration *Configuration) (*Token, error) { return nil, errors.New("Failed to retrieve access token: " + resp.Status) } - responseBody := make([]byte, resp.ContentLength) - _, err = resp.Body.Read(responseBody) + defer func(Body io.ReadCloser) { + _ = Body.Close() + }(resp.Body) + + responseBody, err := io.ReadAll(resp.Body) if err != nil { return nil, err }