-
|
In cases where the client is using a bearer token, it's quite common for such tokens to have expiry timestamps on them such as JWT tokens. For these to be used effectively requires the tokens to be refreshed as they expire and preferably on demand rather than trying to setup some background cron service. In a sync client, I believe this can be done with event hooks by checking the token each time and fetching a new one if it has expired before the request is sent. However in an async client, I don't believe there is currently a way to do this in the client itself because hooks cannot be async and thus cannot suspend the task while it awaits a separate HTTP call to fetch a new bearer token. It would be really great if there were a solution to this. Either via the introduction of async hooks or otherwise an authentication source that supported async. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Apologies. I missed this in the documentation. This is actually well documented under Custom Authentication Schemes: |
Beta Was this translation helpful? Give feedback.
Apologies. I missed this in the documentation. This is actually well documented under Custom Authentication Schemes:
https://www.python-httpx.org/advanced/authentication/