Skip to content

refactor(googleapi): extract authenticatedTransport and add NewHTTPCl…#534

Closed
johnbenjaminlewis wants to merge 1 commit intoopenclaw:mainfrom
johnbenjaminlewis:refactor/authenticated-transport
Closed

refactor(googleapi): extract authenticatedTransport and add NewHTTPCl…#534
johnbenjaminlewis wants to merge 1 commit intoopenclaw:mainfrom
johnbenjaminlewis:refactor/authenticated-transport

Conversation

@johnbenjaminlewis
Copy link
Copy Markdown
Contributor

@johnbenjaminlewis johnbenjaminlewis commented Apr 27, 2026

refactor(googleapi): extract authenticatedTransport and add NewHTTPClient

Dependency for #535 ⚠️ only merge this if you plan to merge #535 ⚠️

Summary

  • Extracts the OAuth transport setup from optionsForAccountScopes into a reusable authenticatedTransport helper, removing duplication between the existing google-api-go client path and callers that need a raw *http.Client
  • Adds NewHTTPClient(ctx, service, email) for callers that need to set their own policies (e.g. custom CheckRedirect) on the HTTP client rather than going through option.WithHTTPClient
  • Minor test cleanup: switches newDocsServiceForTest to use t.Cleanup instead of returning a manual close func

Test plan

  • TestNewHTTPClient_NoRedirectPolicy verifies the returned client has no redirect policy set (callers can add their own)
  • TestOptionsForAccountScopes_NoClientTimeout continues to pass, confirming no regression in the existing path
  • make test passes

…ient

Factor out the OAuth transport setup from optionsForAccountScopes into
a reusable authenticatedTransport helper. Expose NewHTTPClient so
callers that need a raw *http.Client (e.g. for custom redirect
policies) can get one without going through the google-api-go options
layer.
@steipete
Copy link
Copy Markdown
Collaborator

Landed on main in 8f6791f with the changelog credit added.

Kept the transport extraction/NewHTTPClient shape from the PR, applied it on top of the current auth subject-backfill changes, and preserved co-author credit.

Verification:

  • go test ./internal/googleapi ./internal/cmd -run 'TestNewHTTPClient|TestOptionsForAccountScopes_NoClientTimeout|TestDocs' -count=1\n- make lint\n- make test\n- make ci\n\nThanks @johnbenjaminlewis.

@steipete steipete closed this Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants