Add debug message in GetToken function

This commit is contained in:
Evan Fiordeliso 2024-03-07 18:37:38 -05:00
parent 4803b82eba
commit 98d925636c
1 changed files with 8 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package auth
import ( import (
"encoding/json" "encoding/json"
"log/slog"
"net/http" "net/http"
"time" "time"
@ -57,8 +58,14 @@ func GetToken(params *GetTokenParams) (*Token, error) {
} }
defer res.Body.Close() defer res.Body.Close()
body := make([]byte, res.ContentLength)
if _, err := res.Body.Read(body); err != nil {
return nil, err
}
var token Token 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 return nil, err
} }