fix: Use urlencoded body for get token request
This commit is contained in:
parent
98d925636c
commit
8bbafd2ee7
|
@ -2,8 +2,8 @@ package auth
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/google/go-querystring/query"
|
||||
|
@ -52,20 +52,14 @@ func GetToken(params *GetTokenParams) (*Token, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
res, err := http.Get(TokenUrl + "?" + v.Encode())
|
||||
res, err := http.Post(TokenUrl, "application/x-www-form-urlencoded", strings.NewReader(v.Encode()))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
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.Unmarshal(body, &token); err != nil {
|
||||
slog.Debug("failed to decode token", slog.Any("error", err), slog.String("body", string(body)))
|
||||
if err := json.NewDecoder(res.Body).Decode(&token); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue