danielberkompas / ex_twilio

Twilio API client for Elixir
MIT License
336 stars 147 forks source link

Support Twilio API key-based authentication #173

Open matt-glover opened 2 years ago

matt-glover commented 2 years ago

This PR adds support for API key auth as discussed in https://github.com/danielberkompas/ex_twilio/issues/124

With this change callers to APIs are able to pass api_key and api_secret options to the various REST API calls to use API key-based auth in place of the account token-based auth. This works by following the pattern of the optional account/token params already supported for sub-account auth.

I will admit I do not know Twilio's various APIs all that well or the internals of this library all that well. So my manual testing was limited to the ExTwilio.Message.create function which is the only place I happen to need this functionality.

When using API keys for auth you still need the account-level SID in your ExTwilio configuration but the account-level auth token can be omitted.

Also happy to do some other manual testing or revisit this approach, with a little guidance, if this PR seems way off the mark.