httpx_auth icon indicating copy to clipboard operation
httpx_auth copied to clipboard

Allow nest token_field_name with OAuth2ClientCredentials

Open valentincalomme opened this issue 2 months ago • 1 comments

My use case is simple, I need to use a OAuth2ClientCredentials authentication flow, but my access token is not returned at the top-level of the response's JSON body, instead, the field is nested, i.e.

{
  "tokenData": {
    "access_token": "tYGB6EHKxzMs9ecUFhPxDtXflaPKqHACIvcrd4Wx",
    "token_type": "Bearer",
    "expires_in": 60000
  },
  "errors": [],
  "success": true
}

My proposed solution would be to allow the token_field_name parameter to be a tuple, to reflect the nested structure (i.e. ("tokenData", "access_token"))

valentincalomme avatar Oct 20 '25 08:10 valentincalomme

Hello, while the use case is correct, the proposed solution is not enough as we need to extract the expiry as well (at least, there is also error management to do). Could you share what provider this is? Maybe they document what the provide in case of success and error ?

Colin-b avatar Oct 20 '25 20:10 Colin-b