From 730a7a66cea5215aa2feaa81bb66da3a2d86ee64 Mon Sep 17 00:00:00 2001 From: Victor Xirau Guardans Date: Mon, 15 Jul 2024 11:35:29 +0200 Subject: [PATCH] Changed content type to url encoded to allow for new API version, and fixes token creation --- internal/woffuapi/token.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/woffuapi/token.go b/internal/woffuapi/token.go index de2eabd..09a59bf 100644 --- a/internal/woffuapi/token.go +++ b/internal/woffuapi/token.go @@ -22,15 +22,16 @@ func (w WoffuAPI) CreateToken() (*TokenResponse, error) { credentials := strings.Split(w.auth.Credentials(), ":") // Build API Request + body := fmt.Sprintf("grant_type=password&username=%s&password=%s", credentials[0], credentials[1]) apiRequest := APIRequest{ method: "POST", endpoint: "/token", headers: map[string]string{ "Accept": "application/json", - "Content-Type": "application/json", + "Content-Type": "application/x-www-form-urlencoded", }, // Credentials need to be passed in the body :S - body: []byte(fmt.Sprintf("grant_type=password&username=%s&password=%s", credentials[0], credentials[1])), + body: []byte(body), } // Get Token