Easee: use oauth validity check to utilize tokens expiryDelta
This commit is contained in:
parent
b717a51436
commit
fe79ba8b02
1 changed files with 1 additions and 2 deletions
|
|
@ -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 == "" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue