Windows: add console OAuth fallback when local server ports are blocked #515
+155
−49
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.