Re-add debug message to get token function

This commit is contained in:
Evan Fiordeliso 2024-03-07 18:45:59 -05:00
parent 8bbafd2ee7
commit 3d97b0174b
1 changed files with 8 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package auth
import (
"encoding/json"
"log/slog"
"net/http"
"strings"
"time"
@ -58,8 +59,14 @@ func GetToken(params *GetTokenParams) (*Token, error) {
}
defer res.Body.Close()
body := make([]byte, res.ContentLength)
if _, err := res.Body.Read(body); err != nil {
return nil, err
}
var token Token
if err := json.NewDecoder(res.Body).Decode(&token); err != nil {
if err := json.Unmarshal(body, &token); err != nil {
slog.Debug("failed to decode token", slog.Any("error", err), slog.String("body", string(body)))
return nil, err
}