django-rest-framework-passwordless
django-rest-framework-passwordless copied to clipboard
Twilio bug
hey, thanks for package @aaronn
bug in send_sms_with_callback_token()
twilio_client.messages.create(
body=base_string % mobile_token.key,
to=to_number,
from_=api_settings.PASSWORDLESS_MOBILE_NOREPLY_NUMBER
)
to_number
should have "+"
otherwise twilio client doesn't work
and it was hard to catch the error, since passwordless doesn't pass Twilio's error
cheers!
Sometimes the "+" prefix is there, sometimes it's not. It depends on what you pass in, as it seems there is nothing in the codebase to enforce the prefix. What's even more problematic is that if you follow the README.md instructions, you will end up without it, and getting the error you mentioned:
curl -X POST -d "mobile=+15552143912" localhost:8000/auth/mobile/
should be revised to:
curl -X POST -d "mobile=%2B15552143912" localhost:8000/auth/mobile/
Otherwise the plus symbol will be dropped for me. I agree the lack of errors being passed is also not ideal.
it doesn't work till. @crj1001 even after using %2B instead of + any help would be appreciated!

there is actually no bug. got it to work
- confirm your TWILIO_ACCOUNT_SID
- confirm your TWILIO_AUTH_TOKEN
- confirm your TWILIO_PHONE_NUMBER
- Add them to your .env file
- Use os.environ.get('*****') to get them where needed
- if using docker, you would have to rebuild the whole container for the changes to show
-
docker-compose up --build
- when testing with Twilio trial acc remember to register the number you testing with.
This my config in my settings.py
`PASSWORDLESS_AUTH = {
'PASSWORDLESS_AUTH_TYPES': ['EMAIL', 'MOBILE'],
'PASSWORDLESS_EMAIL_NOREPLY_ADDRESS': DEFAULT_FROM_EMAIL,
'PASSWORDLESS_USER_MOBILE_FIELD_NAME': 'mobile',
'PASSWORDLESS_MOBILE_NOREPLY_NUMBER': \
os.environ.get('TWILIO_PHONE_NUMBER'),
'PASSWORDLESS_EMAIL_TOKEN_HTML_TEMPLATE_NAME': "core/auth.html"
}`
