BMW: extract login error message

This commit is contained in:
andig 2023-12-07 08:19:51 +01:00
parent 10c131647d
commit f3c814a51b

View file

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