refactor: improve response body handling in token retrieval

This commit is contained in:
2025-06-25 12:36:00 -04:00
parent 95bb27698b
commit f68538e66f

View File

@@ -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
}