From c2822413b190e3b6b03c58f5639428a45ba0abda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Ferrand?= Date: Mon, 3 Jan 2022 13:55:00 +0100 Subject: [PATCH] Adapt authentication to new auth style * See #1 --- .gitignore | 1 + api/v1/authentication.go | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/.gitignore b/.gitignore index 16e654d..d9f7441 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.pdf ensap-payroll-cli ensap +ensap-cli /dist diff --git a/api/v1/authentication.go b/api/v1/authentication.go index 7bfb32c..abacbb7 100644 --- a/api/v1/authentication.go +++ b/api/v1/authentication.go @@ -66,6 +66,8 @@ func (c *ensapV1APIClient) Login() error { endpoint := c.buildFullEndpoint(api.AuthentificationEndpoint, false) + log.Debugf("logging in using endpoint %s", endpoint) + req, err := http.NewRequestWithContext(c.ctx, http.MethodPost, endpoint, strings.NewReader(formData.Encode())) if err != nil { return errors.Wrap(err, "creating request object") @@ -73,6 +75,11 @@ func (c *ensapV1APIClient) Login() error { c.setRequestUserAgent(req) req.Header.Set("Content-Type", "application/x-www-form-urlencoded") + req.Header.Set("Accept", "application/json") + + // if c.cfg.Debug { + // debugDumpHTTPRequest("Login", req, true) + // } resp, err := c.httpClient.Do(req) if err != nil {