From f3c814a51bbbecb504d178ef0022b68d7471a9e8 Mon Sep 17 00:00:00 2001 From: andig Date: Thu, 7 Dec 2023 08:19:51 +0100 Subject: [PATCH] BMW: extract login error message --- vehicle/bmw/identity.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vehicle/bmw/identity.go b/vehicle/bmw/identity.go index 6c2c219a3..f6ae9ecaa 100644 --- a/vehicle/bmw/identity.go +++ b/vehicle/bmw/identity.go @@ -66,10 +66,15 @@ func (v *Identity) Login(user, password string) (oauth2.TokenSource, error) { } var res struct { - RedirectTo string `json:"redirect_to"` + RedirectTo string `json:"redirect_to"` + Error string `json:"error"` + ErrorDescription string `json:"error_description"` } if err := v.DoJSON(req, &res); err != nil { + if res.ErrorDescription != "" { + err = fmt.Errorf("%s: %w", res.ErrorDescription, err) + } return nil, err }