Windows: add console OAuth fallback when local server ports are blocked#515
Open
Foadsf wants to merge 3 commits into
Open
Windows: add console OAuth fallback when local server ports are blocked#515Foadsf wants to merge 3 commits into
Foadsf wants to merge 3 commits into
Conversation
On Windows systems where ports 8080–8099 are blocked (e.g. by firewall,
AV, or Docker Desktop), GYB’s OAuth flow fails with WinError 10013
because `_wait_for_http_client` cannot bind a local HTTP listener.
This prevents any authentication from succeeding.
This patch implements a robust fallback:
* `_wait_for_http_client`:
- Wrapped in try/except, signals `d['error'] = 'local_server_failed'`
instead of crashing when no port can be bound.
- Leaves the original local server flow unchanged when ports are free.
* `ShortURLFlow`:
- Added `__init__` to capture and persist OAuth scopes in
`self._gyb_scopes`.
- Enhanced `run_dual` to detect `local_server_failed` and
transparently switch to a manual console flow:
- Generates an authorization URL with `http://localhost` redirect.
- Opens browser if possible.
- Prompts user to paste either the full redirect URL or just the
`code` value.
- Exchanges the code with `self.fetch_token()` and returns
credentials.
Key design decisions:
- Reuse the existing flow object (`self`) to maintain state consistency.
- Avoid passing `redirect_uri` again to `fetch_token()` to prevent
conflicts.
- Accept both full redirect URLs and raw codes for user convenience.
- Added docstrings and commented debug logging for future diagnosis.
This resolves authentication failures on Windows while preserving
backward compatibility on platforms where the local server works.
Fixes: GAM-team#370
Tested:
- `--action estimate`, `--action count`, and `--action print-labels`
complete successfully with cached `oauth2.txt` after console flow.
Author
|
Pushed a fix for the UnboundLocalError caused by local variable shadowing of urlparse. Verified working on Windows. |
Author
|
Updated PR with fix for httplib2 certificate environment variable in Miniconda setups |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Windows systems where ports 8080–8099 are blocked (e.g. by firewall, AV, or Docker Desktop), GYB’s OAuth flow fails with WinError 10013 because
_wait_for_http_clientcannot bind a local HTTP listener. This prevents any authentication from succeeding.This patch implements a robust fallback:
_wait_for_http_client:d['error'] = 'local_server_failed'instead of crashing when no port can be bound.ShortURLFlow:__init__to capture and persist OAuth scopes inself._gyb_scopes.run_dualto detectlocal_server_failedand transparently switch to a manual console flow:http://localhostredirect.codevalue. - Exchanges the code withself.fetch_token()and returns credentials.Key design decisions:
self) to maintain state consistency.redirect_uriagain tofetch_token()to prevent conflicts.This resolves authentication failures on Windows while preserving backward compatibility on platforms where the local server works.
Fixes: #370
Tested:
--action estimate,--action count, and--action print-labelscomplete successfully with cachedoauth2.txtafter console flow.