From 1fa5514d56c8ff7a56ecfca91ffb91839e752995 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 9 Dec 2025 20:13:16 +0800 Subject: [PATCH] fix kiro cannot refresh the token --- internal/watcher/watcher.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/internal/watcher/watcher.go b/internal/watcher/watcher.go index da152141..36276de9 100644 --- a/internal/watcher/watcher.go +++ b/internal/watcher/watcher.go @@ -1272,7 +1272,7 @@ func (w *Watcher) SnapshotCoreAuths() []*coreauth.Auth { } for i := range cfg.KiroKey { kk := cfg.KiroKey[i] - var accessToken, profileArn string + var accessToken, profileArn, refreshToken string // Try to load from token file first if kk.TokenFile != "" && kAuth != nil { @@ -1282,6 +1282,7 @@ func (w *Watcher) SnapshotCoreAuths() []*coreauth.Auth { } else { accessToken = tokenData.AccessToken profileArn = tokenData.ProfileArn + refreshToken = tokenData.RefreshToken } } @@ -1292,6 +1293,9 @@ func (w *Watcher) SnapshotCoreAuths() []*coreauth.Auth { if kk.ProfileArn != "" { profileArn = kk.ProfileArn } + if kk.RefreshToken != "" { + refreshToken = kk.RefreshToken + } if accessToken == "" { log.Warnf("kiro config[%d] missing access_token, skipping", i) @@ -1313,6 +1317,9 @@ func (w *Watcher) SnapshotCoreAuths() []*coreauth.Auth { if kk.AgentTaskType != "" { attrs["agent_task_type"] = kk.AgentTaskType } + if refreshToken != "" { + attrs["refresh_token"] = refreshToken + } proxyURL := strings.TrimSpace(kk.ProxyURL) a := &coreauth.Auth{ ID: id, @@ -1324,6 +1331,14 @@ func (w *Watcher) SnapshotCoreAuths() []*coreauth.Auth { CreatedAt: now, UpdatedAt: now, } + + if refreshToken != "" { + if a.Metadata == nil { + a.Metadata = make(map[string]any) + } + a.Metadata["refresh_token"] = refreshToken + } + out = append(out, a) } for i := range cfg.OpenAICompatibility {