Manager owns the OAuth login flows and the resulting (refreshing) token for a single stdio session. It is safe for concurrent use; only one authorization flow runs at a time.
| 55 | // single stdio session. It is safe for concurrent use; only one authorization |
| 56 | // flow runs at a time. |
| 57 | type Manager struct { |
| 58 | config Config |
| 59 | refreshConfig *oauth2.Config |
| 60 | logger *slog.Logger |
| 61 | |
| 62 | // Test seams, set by NewManager to real implementations. |
| 63 | openURL func(string) error |
| 64 | inDocker func() bool |
| 65 | |
| 66 | mu sync.Mutex |
| 67 | source oauth2.TokenSource // refreshing source, set once authorized |
| 68 | status flowStatus |
| 69 | pending *UserAction |
| 70 | done chan struct{} |
| 71 | lastErr error |
| 72 | refreshErrLogged bool // true once a refresh failure has been logged, reset on re-auth |
| 73 | } |
| 74 | |
| 75 | // NewManager builds a Manager for the given configuration. A nil logger logs to |
| 76 | // stderr. |
nothing calls this directly
no outgoing calls
no test coverage detected