complete records the flow result, installing a refreshing token source on success, and wakes any joined callers.
(tok *oauth2.Token, err error)
| 249 | // complete records the flow result, installing a refreshing token source on |
| 250 | // success, and wakes any joined callers. |
| 251 | func (m *Manager) complete(tok *oauth2.Token, err error) { |
| 252 | m.mu.Lock() |
| 253 | defer m.mu.Unlock() |
| 254 | |
| 255 | m.status = statusIdle |
| 256 | m.pending = nil |
| 257 | if err != nil { |
| 258 | m.lastErr = err |
| 259 | m.logger.Debug("oauth flow failed", "error", err) |
| 260 | } else { |
| 261 | m.lastErr = nil |
| 262 | // Config.TokenSource returns a ReuseTokenSource that refreshes expired |
| 263 | // tokens using the refresh token — this is what makes GitHub App |
| 264 | // (expiring) tokens work transparently. The refresh uses a bounded HTTP |
| 265 | // client so a stalled token endpoint can't block a tool call forever. |
| 266 | refreshCtx := context.WithValue(context.Background(), oauth2.HTTPClient, &http.Client{Timeout: tokenRefreshTimeout}) |
| 267 | m.source = m.refreshConfig.TokenSource(refreshCtx, tok) |
| 268 | m.refreshErrLogged = false |
| 269 | m.logger.Info("github authorization complete") |
| 270 | } |
| 271 | if m.done != nil { |
| 272 | close(m.done) |
| 273 | m.done = nil |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | // joinWait blocks until the running flow finishes or ctx is cancelled. If the |
| 278 | // flow was promoted to the manual channel while waiting (its prompt could not be |
no outgoing calls
no test coverage detected