make 'oauth_client' more flexible

Open
#750 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
r

Research direction

Start in R/oauth-client.R at oauth_client and oauth_client_get_token, using the linked locations as entry points; review related issue #435 for context. Determine how the proxy setting should apply across authorization, device, and client-credentials flows, then verify that token requests use the configured proxy when present and remain unchanged otherwise.

Written by the indexing model from the issue text.

Description

We have a use case, where depending on the system the code runs, it uses OAuth2 via authorisation flow, device flow or client credentials, with proxy and without proxy. In order to write simple code that works in any of these cases, would it make sense to add 'proxy' argument to 'oauth_client'

https://github.com/r-lib/httr2/blob/f52f4b92159fda233e3de7b0566d67c51bf5a282/R/oauth-client.R#L42

oauth_client <- function(
  id,
  token_url,
  secret = NULL,
  key = NULL,
  auth = c("body", "header", "jwt_sig"),
  auth_params = list(),
  name = hash(id),
  proxy = NULL
) {

Then, in oauth_client_get_token one would do something like

https://github.com/r-lib/httr2/blob/f52f4b92159fda233e3de7b0566d67c51bf5a282/R/oauth-client.R#L243

if(!is.null(client$proxy))
  req <- req_proxy(req, client$proxy)

We would then create the oauth_client with

client <- oauth_client(
  id = "28acfec0674bb3da9f38",
  token_url = "https://github.com/login/oauth/access_token",
  name = "oauth-test-2",
  proxy = curl::ie_get_proxy_for_url()
)

related #435

At the moment we use AzureAuth and httr::use_proxy.

Thanks

Dominant language
R
Stars
270
Forks
91
Avg merge
3d 16h
Merged PRs (30d)
3

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from r-lib/httr2

All issues in r-lib/httr2

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.