fix: Use urlencoded body for get token request
This commit is contained in:
parent
98d925636c
commit
8bbafd2ee7
|
@ -2,8 +2,8 @@ package auth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"log/slog"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
@ -52,20 +52,14 @@ func GetToken(params *GetTokenParams) (*Token, error) {
|
||||||
return nil, err
|
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 {
|
if err != nil {
|
||||||
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 {
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue