joinWait blocks until the running flow finishes or ctx is cancelled. If the flow was promoted to the manual channel while waiting (its prompt could not be delivered), it returns that user action rather than an error.
(ctx context.Context, done chan struct{})
| 278 | // flow was promoted to the manual channel while waiting (its prompt could not be |
| 279 | // delivered), it returns that user action rather than an error. |
| 280 | func (m *Manager) joinWait(ctx context.Context, done chan struct{}) (*Outcome, error) { |
| 281 | select { |
| 282 | case <-done: |
| 283 | if m.AccessToken() != "" { |
| 284 | return nil, nil |
| 285 | } |
| 286 | m.mu.Lock() |
| 287 | pending := m.pending |
| 288 | err := m.lastErr |
| 289 | m.mu.Unlock() |
| 290 | if pending != nil { |
| 291 | return &Outcome{UserAction: pending}, nil |
| 292 | } |
| 293 | if err != nil { |
| 294 | return nil, err |
| 295 | } |
| 296 | return nil, errors.New("authorization did not complete") |
| 297 | case <-ctx.Done(): |
| 298 | return nil, ctx.Err() |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | func (m *Manager) oauth2Config(redirectURL string) *oauth2.Config { |
| 303 | return &oauth2.Config{ |
no test coverage detected