Skip to content

feat: add HTTP proxy support via environment variables#423

Open
femto wants to merge 2 commits intogoogleworkspace:mainfrom
femto:feat/proxy-support
Open

feat: add HTTP proxy support via environment variables#423
femto wants to merge 2 commits intogoogleworkspace:mainfrom
femto:feat/proxy-support

Conversation

@femto
Copy link

@femto femto commented Mar 12, 2026

Summary

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 and SOCKS support
  • src/auth.rs:
    • Add has_proxy_env() helper to detect proxy environment variables
    • Add refresh_token_with_reqwest() for proxy-aware token refresh
    • When proxy env vars are detected, use reqwest directly instead of waiting for yup-oauth2's hyper client to timeout

Testing

Tested in an environment requiring HTTP proxy:

export https_proxy=http://127.0.0.1:7890
gws drive files list --params '{"pageSize": 5}'
# Works! Completes in ~2 seconds

Without this change, the command would hang waiting for hyper's connection timeout, then fail.

Fixes #422

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@femto femto requested a review from jpoehnelt as a code owner March 12, 2026 04:42
@changeset-bot
Copy link

changeset-bot bot commented Mar 12, 2026

⚠️ No Changeset found

Latest commit: 3758274

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@google-cla
Copy link

google-cla bot commented Mar 12, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@googleworkspace-bot
Copy link
Collaborator

/gemini review

@femto
Copy link
Author

femto commented Mar 12, 2026

@google-cla check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support HTTP proxy environment variables (http_proxy/https_proxy)

2 participants