1

I have been using django-twilio for a while now to send SMS messages to users of my application. My setup is fairly simple, quite similar to the django-twilio docs. I am storing the credentials inside my virtualenv /bin/activate.sh.

I am then using the django-twilio discover_twilio_credentials() to retrieve the credentials.

account_sid, auth_token = discover_twilio_credentials(request.user)
client = TwilioRestClient(account_sid, auth_token)

This works fine, however discover_twilio_credentials() is expecting a user instance passed to it. I now need to be able to send sms without the user making a post, so i need to get the twilio credentials without the user instance. The obvious solution to this would be to have a User instance which is just for getting the credentials but it doesn't seem very nice!

So does anyone know how to get discover_twilio_credentials() without a user instance?

1 Answer 1

2

You shouldn't need to pass in a user instance. It seems that discover_twilio_credentials tries multiple ways to get Twilio creds. If you pass it a user, then it will try to find credentials specific to that user. If that fails, then it falls back to environment variables, so it should find the values from your activate.sh script.

https://github.com/rdegges/django-twilio/blob/master/django_twilio/utils.py#L19-L31

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.