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
This commit is contained in:
Andreas Linde 2021-03-01 15:05:24 +01:00 • committed by GitHub
parent 734839fb16
commit 8ea528ec04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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
}