From a439ca8002d8f89ba2d01a7a088b954507daed39 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sun, 11 Feb 2024 22:32:22 -0500 Subject: [PATCH] fix: only run keep alive if loading token is a success --- api/oauth.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/api/oauth.go b/api/oauth.go index 681585f..47c595c 100644 --- a/api/oauth.go +++ b/api/oauth.go @@ -49,8 +49,9 @@ func (o Oauth) config() *oauth2.Config { } } - o.loadToken(o.oauthCfg) - o.keepAlive() + if o.loadToken(o.oauthCfg) { + o.keepAlive() + } return o.oauthCfg } @@ -59,7 +60,7 @@ func (o Oauth) authUrl() string { return o.config().AuthCodeURL("state") } -func (o Oauth) loadToken(config *oauth2.Config) { +func (o Oauth) loadToken(config *oauth2.Config) bool { token := &oauth2.Token{} if o.cfg.Oauth.Token != "" { @@ -92,11 +93,13 @@ func (o Oauth) loadToken(config *oauth2.Config) { token = o.token } else { o.logger.Info("Token is expired, ignoring") + return false } } } o.refresher = config.TokenSource(context.Background(), token) + return true } func (o Oauth) keepAlive() {