httr2 icon indicating copy to clipboard operation
httr2 copied to clipboard

req_oauth_bearer_jwt requires claim twice

Open drmowinckels opened this issue 1 month ago • 2 comments

I've found that to use req_oauth_bearer_jwt the jwt_claim needs to be passed in two instances for httr2 to not error. It needs to be

  • in the function it self (else function errors with "claim missing with no default")
  • in the client auth_params (else errors with "client needs jwt_claim in auth_params when using jwt_sig")

Is it really necessary to pass the claim twice, or should not the claim be passed from the client to the function (like the "key" parameter is)?

claim <- jwt_claim()

httr2::req_oauth_bearer_jwt(
  claim = claim,
  client = meetupr_client(
    key = "/path/to/key.pem",
    auth = "jwt_sig",
    auth_params = list(
      claim = claim
    )
  )
)

drmowinckels avatar Dec 09 '25 11:12 drmowinckels

Definitely sounds like a bug to me. Do you want to have a go at a PR? I have literally no recollection of how this code works, but presumably you just need to pass claim somewhere extra.

hadley avatar Dec 09 '25 13:12 hadley

I'll have a look and see what I can figure out. Would you prefer the claim to come from the client or the other way around?

drmowinckels avatar Dec 09 '25 13:12 drmowinckels