feat: add HTTP proxy support via environment variables#622
feat: add HTTP proxy support via environment variables#622femto wants to merge 4 commits intogoogleworkspace:mainfrom
Conversation
When http_proxy/https_proxy/all_proxy environment variables are set, use reqwest (which natively supports proxy) for token refresh instead of yup-oauth2's hyper-based client (which doesn't support proxy). This enables gws to work in environments that require HTTP proxy to access Google APIs (e.g., users in China). Changes: - Cargo.toml: Enable reqwest's default features including proxy support - src/auth.rs: Add proxy-aware token refresh using reqwest as fallback Fixes googleworkspace#422
When proxy env vars are set, use a custom OAuth flow with reqwest for token exchange instead of yup-oauth2's hyper-based client. Changes to auth_commands.rs: - Add login_with_proxy_support() for proxy-aware OAuth login - Add exchange_code_with_reqwest() for token exchange via reqwest - Detect proxy env vars and choose appropriate flow
🦋 Changeset detectedLatest commit: ec20bdf The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces proxy support for OAuth authentication flows in the Google Workspace CLI. This is achieved by adding the socks feature to the reqwest dependency and implementing new functions that leverage reqwest for proxy-aware token refreshing and authorization code exchange. The existing authentication logic has been updated to conditionally use these new proxy-aware flows when proxy environment variables are detected. Unit tests for the new proxy-related utilities have also been added. The review comments suggest that creating a new reqwest::Client for each function call is inefficient and recommend using a single, shared client instance across the application to improve performance.
|
Addressed the reqwest client reuse feedback by adding a shared client helper backed by std::sync::OnceLock in crates/google-workspace/src/client.rs and switching the proxy auth flows to use it. |
Summary
When
http_proxy/https_proxy/all_proxyenvironment variables are set, usereqwest(which supports proxy env vars natively) for token refresh and the auth login token exchange instead of relying only onyup-oauth2'shyper-based client.This enables
gwsto work in environments that require an HTTP proxy to access Google APIs.Supersedes closed PR #423 after rebasing onto the cargo workspace refactor.
Changes
crates/google-workspace-cli/src/auth.rsreqwestcrates/google-workspace-cli/src/auth_commands.rscrates/google-workspace-cli/Cargo.tomlreqwestconfigured with SOCKS support in the workspace crate.changeset/proxy-support-review-fixes.mdTesting
cargo clippy -p google-workspace-cli -- -D warningscargo test -p google-workspace-cli auth::tests::cargo test -p google-workspace-cli auth_commands::tests::