From 6be3ed02d1f830ed162d9cfc8f1e40ceff9660e4 Mon Sep 17 00:00:00 2001 From: hurzhurz <16383058+hurzhurz@users.noreply.github.com> Date: Tue, 17 Sep 2024 22:24:34 +0200 Subject: [PATCH] PSA: delete token from settings db if invalid (#16183) --- vehicle/psa/identity.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vehicle/psa/identity.go b/vehicle/psa/identity.go index 3437f15996..67d1e39bc9 100644 --- a/vehicle/psa/identity.go +++ b/vehicle/psa/identity.go @@ -71,6 +71,9 @@ func (v *Identity) RefreshToken(token *oauth2.Token) (*oauth2.Token, error) { tok, err := v.oc.TokenSource(ctx, token).Token() if err != nil { + if strings.Contains(err.Error(), "invalid_grant") { + settings.Delete(v.subject) + } return nil, err }