MCPcopy Create free account
hub / github.com/Quorinex/Kiro-Go / apiAddAccount

Method apiAddAccount

proxy/handler.go:2335–2366  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

2333 "",
2334 )
2335 return false, nil
2336 }
2337
2338 if !force && (working.ExpiresAt == 0 || time.Now().Unix() < working.ExpiresAt-tokenRefreshSkewSeconds) {
2339 h.pool.UpdateCredentialState(
2340 account,
2341 working.ID,
2342 working.AccessToken,
2343 working.RefreshToken,
2344 working.ExpiresAt,
2345 working.ProfileArn,
2346 )
2347 return false, nil
2348 }
2349 if strings.TrimSpace(working.RefreshToken) == "" {
2350 return false, fmt.Errorf("account %s has no refresh token", working.ID)
2351 }
2352
2353 accessToken, refreshToken, expiresAt, profileArn, err := auth.RefreshToken(&working)
2354 if err != nil {
2355 return false, err
2356 }
2357 if refreshToken == "" {
2358 refreshToken = working.RefreshToken
2359 }
2360
2361 if err := config.UpdateAccountCredentialState(
2362 working.ID,
2363 accessToken,
2364 refreshToken,
2365 expiresAt,
2366 profileArn,
2367 ); err != nil {
2368 return false, fmt.Errorf("persist refreshed token for account %s: %w", working.ID, err)
2369 }

Callers 1

handleAdminAPIMethod · 0.95

Calls 6

GenerateAccountIDFunction · 0.92
AddAccountFunction · 0.92
WarnfFunction · 0.92
ErrorMethod · 0.80
ReloadMethod · 0.80

Tested by

no test coverage detected