From 8ea528ec04e4201fd916e14e6710b4c5d4044928 Mon Sep 17 00:00:00 2001 From: Andreas Linde <42185+DerAndereAndi@users.noreply.github.com> Date: Mon, 1 Mar 2021 15:05:24 +0100 Subject: [PATCH] Support MCC charger firmware version 2925 (#713) The new charger software version 2925 now requires all requests to be a referer value, otherwise all requests will fail with HTTP 401 --- charger/mcc.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/charger/mcc.go b/charger/mcc.go index dab863fb6..a8b223966 100644 --- a/charger/mcc.go +++ b/charger/mcc.go @@ -127,7 +127,10 @@ func (mcc *MobileConnect) login(password string) error { "pass": []string{mcc.password}, } - req, err := request.New(http.MethodPost, uri, strings.NewReader(data.Encode()), request.URLEncoding) + req, err := request.New(http.MethodPost, uri, strings.NewReader(data.Encode()), map[string]string{ + "Referer": fmt.Sprintf("%s/login", mcc.uri), + "Content-Type": "application/x-www-form-urlencoded", + }) if err != nil { return err } @@ -172,6 +175,7 @@ func (mcc *MobileConnect) request(method, uri string) (*http.Request, error) { } req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", mcc.token)) + req.Header.Set("Referer", fmt.Sprintf("%s/dashboard", mcc.uri)) return req, nil }