Open MrCreosote opened 1 month ago
@MrCreosote what is the complication with just creating a new client? Is it that you have a processing loop with the client context? Something like this?:
async with AsyncClient(client_id, client_secret) as client:
# processing loop
The context is a service that consists of multiple modules that have references to the AsyncClient. That means whenever the credentials are updated, all those references need to be updated to the new client and the old client has to be closed - but it can't be closed immediately as there may be client calls in flight. I have an implementation that does this but it wound up being pretty complex.
If creds can be updated on the fly, we don't have to worry about closing the old client with a delay or replacing references - we just need a cred checking loop with a reference to the client that updates the creds via the method in the issue title.
@MrCreosote Thanks for the context. The AsyncClient
is a wrapper around AsyncOAuth2Client
( which does the oauth flow ). If AsyncOAuth2Client
had a update_credentials
method I would be happy to proxy this call through, however, this is not the case and I am a little reluctant to add the extra complexity to the client, but we can see how this request stack up against other priorities.
It would be very helpful to have a method to update the credentials for a client without having to create a new client. The use case here is a service that contacts the API in a few places in the code base. When the credentials expire, all those clients need to be replaced. If there was an update method, a separate coroutine could monitor a creds file for changes and call the update method and the various parts of the service could wouldn't have to be concerned with replacing the client and closing the old client.