From d0bed7de7e4ee9c82f7124de200b604b7afd5448 Mon Sep 17 00:00:00 2001 From: Zsolt Varga Date: Fri, 24 Jul 2026 17:02:47 +0200 Subject: [PATCH] fix(oauth2ac): don't signal spurious refresh on first authorization --- pkg/oauth2ac/oauth2ac.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/oauth2ac/oauth2ac.go b/pkg/oauth2ac/oauth2ac.go index fe31dc2..be6619b 100644 --- a/pkg/oauth2ac/oauth2ac.go +++ b/pkg/oauth2ac/oauth2ac.go @@ -288,7 +288,8 @@ func (cp *credentialsProvider) Start(ctx context.Context) (<-chan StatusEvent, e } func (cp *credentialsProvider) Authorize(ctx context.Context, authState, code string) (*oauth2.Token, error) { - if !cp.reauthorizeIfAuthorized && cp.syncGate.IsOpen() { + wasAuthorized := cp.syncGate.IsOpen() + if !cp.reauthorizeIfAuthorized && wasAuthorized { return nil, errors.WithStack(ErrAlreadyAuthorized) } @@ -315,7 +316,7 @@ func (cp *credentialsProvider) Authorize(ctx context.Context, authState, code st cp.authorizeSpanContext = sc cp.mu.Unlock() - if cp.syncGate.IsOpen() { + if wasAuthorized { cp.signalRefresh() }