WaitForCallback waits for the OAuth callback with a timeout. It blocks until either an OAuth result is received, an error occurs, or the specified timeout is reached. Parameters: - timeout: The maximum time to wait for the callback Returns: - *OAuthResult: The OAuth result if successful - error: A
(timeout time.Duration)
| 145 | // - *OAuthResult: The OAuth result if successful |
| 146 | // - error: An error if the callback times out or an error occurs |
| 147 | func (s *OAuthServer) WaitForCallback(timeout time.Duration) (*OAuthResult, error) { |
| 148 | select { |
| 149 | case result := <-s.resultChan: |
| 150 | return result, nil |
| 151 | case err := <-s.errorChan: |
| 152 | return nil, err |
| 153 | case <-time.After(timeout): |
| 154 | return nil, fmt.Errorf("timeout waiting for OAuth callback") |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | // handleCallback handles the OAuth callback endpoint. |
| 159 | // It extracts the authorization code and state from the callback URL, |