From fe79ba8b02155e9d7a1ee0ef3534183694b60f65 Mon Sep 17 00:00:00 2001 From: andig Date: Mon, 3 Jul 2023 17:54:55 +0200 Subject: [PATCH] Easee: use oauth validity check to utilize tokens expiryDelta --- util/oauth/tokensource.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/util/oauth/tokensource.go b/util/oauth/tokensource.go index 66dbf0af5..c2007ae31 100644 --- a/util/oauth/tokensource.go +++ b/util/oauth/tokensource.go @@ -3,7 +3,6 @@ package oauth import ( "errors" "sync" - "time" "github.com/imdario/mergo" "golang.org/x/oauth2" @@ -32,7 +31,7 @@ func (ts *TokenSource) Token() (*oauth2.Token, error) { ts.mu.Lock() defer ts.mu.Unlock() var err error - if ts.token == nil || time.Until(ts.token.Expiry) < time.Minute { + if !ts.token.Valid() { var token *oauth2.Token if token, err = ts.refresher.RefreshToken(ts.token); err == nil { if token.AccessToken == "" {