Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Async]Client.update_credentials(client_id=None, secret=None, key=None) method #91

Open
MrCreosote opened this issue Oct 13, 2024 · 3 comments

Comments

@MrCreosote
Copy link
Contributor

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.

@cjh1
Copy link
Collaborator

cjh1 commented Oct 16, 2024

@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

@MrCreosote
Copy link
Contributor Author

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.

@cjh1
Copy link
Collaborator

cjh1 commented Oct 28, 2024

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants