Remove log messages from token endpoint

This commit is contained in:
Evan Fiordeliso 2024-03-07 18:56:09 -05:00
parent a937cb9f58
commit 5c76a4b1c3
1 changed files with 1 additions and 11 deletions

View File

@ -2,7 +2,6 @@ package auth
import ( import (
"encoding/json" "encoding/json"
"log/slog"
"net/http" "net/http"
"strings" "strings"
"time" "time"
@ -50,26 +49,17 @@ type GetTokenParams struct {
func GetToken(params *GetTokenParams) (*Token, error) { func GetToken(params *GetTokenParams) (*Token, error) {
v, err := query.Values(params) v, err := query.Values(params)
if err != nil { if err != nil {
slog.Error("failed to encode token", slog.Any("error", err))
return nil, err return nil, err
} }
res, err := http.Post(TokenUrl, "application/x-www-form-urlencoded", strings.NewReader(v.Encode())) res, err := http.Post(TokenUrl, "application/x-www-form-urlencoded", strings.NewReader(v.Encode()))
if err != nil { if err != nil {
slog.Error("failed to get token", slog.Any("error", err))
return nil, err return nil, err
} }
defer res.Body.Close() 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
}
var token Token var token Token
if err := json.Unmarshal(body, &token); err != nil { if err := json.NewDecoder(res.Body).Decode(&token); err != nil {
slog.Debug("failed to decode token", slog.Any("error", err), slog.String("body", string(body)))
return nil, err return nil, err
} }