Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support user-defined redaction in req_headers() #247

Closed
gvelasq opened this issue Jun 29, 2023 · 2 comments · Fixed by #263
Closed

Support user-defined redaction in req_headers() #247

gvelasq opened this issue Jun 29, 2023 · 2 comments · Fixed by #263

Comments

@gvelasq
Copy link
Contributor

gvelasq commented Jun 29, 2023

The Google Cloud APIs use the x-goog-api-key header to pass API keys. Currently, only the Authorization header is automatically redacted by req_headers(), as implemented in the internal function headers_redact(). x-goog-api-key is therefore not redacted:

library(httr2)

req_google <-
  request("https://www.googleapis.com") %>%
  req_url_path_append("youtube/v3") %>%
  req_headers("x-goog-api-key" = "ABC123XYZ")

req_google
#> <httr2_request>
#> GET https://www.googleapis.com/youtube/v3
#> Headers:
#> • x-goog-api-key: 'ABC123XYZ'
#> Body: empty

Created on 2023-06-29 with reprex v2.0.2

I recently added support for YouTube Data API key authentication in gojiplus/tuber#126, and it would be great to be able to redact the x-goog-api-key header used here for use in continuous integration. More broadly, a .redact = TRUE argument to req_headers() would permit users to redact any header. The desired behavior would look like the code block below:

library(httr2)

req_google <-
  request("https://www.googleapis.com") %>%
  req_url_path_append("youtube/v3") %>%
  req_headers("x-goog-api-key" = "ABC123XYZ", .redact = TRUE)

req_google
#> <httr2_request>
#> GET https://www.googleapis.com/youtube/v3
#> Headers:
#> • x-goog-api-key: '<REDACTED>'
#> Body: empty
@gvelasq
Copy link
Contributor Author

gvelasq commented Aug 9, 2023

Thank you, @mgirlich!

@mgirlich
Copy link
Collaborator

Happy to help 😄

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 a pull request may close this issue.

2 participants