Add more log messages to get token function

This commit is contained in:
Evan Fiordeliso 2024-03-07 18:53:40 -05:00
parent 3d97b0174b
commit a937cb9f58
1 changed files with 3 additions and 0 deletions

View File

@ -50,17 +50,20 @@ type GetTokenParams struct {
func GetToken(params *GetTokenParams) (*Token, error) {
v, err := query.Values(params)
if err != nil {
slog.Error("failed to encode token", slog.Any("error", err))
return nil, err
}
res, err := http.Post(TokenUrl, "application/x-www-form-urlencoded", strings.NewReader(v.Encode()))
if err != nil {
slog.Error("failed to get token", slog.Any("error", err))
return nil, err
}
defer res.Body.Close()
body := make([]byte, res.ContentLength)
if _, err := res.Body.Read(body); err != nil {
slog.Error("failed to read response", slog.Any("error", err))
return nil, err
}