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

TwilioClient for multi-tenancy apps #684

Closed
MikeAlhayek opened this issue Aug 25, 2023 · 3 comments
Closed

TwilioClient for multi-tenancy apps #684

MikeAlhayek opened this issue Aug 25, 2023 · 3 comments

Comments

@MikeAlhayek
Copy link

Currently the C# twilio SDK does not allow us to use it in a multi-tenancy app. The problem with the existing code, is that is stores the username, password and others is a static variable. When you use this SDK with an app that supports multi-tenancy, you may end up using invalid parameters for requests since it is not thread-safe. If your are using an interface for the client, we could have easily replaced your default implementation with once that would work in a multi-tenancy apps.

@Swimburger
Copy link
Contributor

While the docs all use the static client, you can instantiate your own ITwilioRestClient instances.
The Twilio.AspNet.Core library doesn't support multi-tenancy, but you can inspire on the source code and add support for it yourself: https://github.com/twilio-labs/twilio-aspnet/blob/main/src/Twilio.AspNet.Core/TwilioClientDependencyInjectionExtensions.cs

@jassent
Copy link

jassent commented Jan 3, 2024

This thread on Stackoverflow titled "What Pattern to Use for TwilioRestClient with Dependency Injection" shows how to use TwilioClient in a multi-tenancy app. I can confirm it works and have 1 app that accesses multiple accounts with different AccountSid and AuthToken combinations and it interfaces with Polly v7 as well as Polly v8 for resilient httpclients.

@tiwarishubham635
Copy link
Contributor

Closing this issue as resolved by above comments

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

4 participants