You've already forked email-api-client
refactor: improve response body handling in token retrieval
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user