aaronn / django-rest-framework-passwordless

Passwordless Auth for Django REST Framework
MIT License
717 stars 154 forks source link

How to use other otp provider like - msg91 #95

Open raghvpip3 opened 3 years ago

raghvpip3 commented 3 years ago

How to use other OTP provider like - msg91

jaymes15 commented 3 years ago

@raghvpip3 were you able to get it working with Twilio?

raghvpip3 commented 3 years ago

yes, its working, but I am curious this package will work with other OTP provider or only support for twilio?

jaymes15 commented 3 years ago

I was only able to get it to work with email

jaymes15 commented 3 years ago

This the config I used

`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"

}`

jaymes15 commented 3 years ago

any help would be appreciated

Screen Shot 2021-09-17 at 6 47 07 AM
jaymes15 commented 3 years ago

got it it work

Screen Shot 2021-09-17 at 7 24 03 AM

s

dubesar commented 3 years ago

@jaymes15 i am getting the same error, can you share your configs?

jaymes15 commented 3 years ago

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_USE_TLS = False EMAIL_HOST = os.environ.get('EMAIL_HOST') EMAIL_PORT = 587 EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER') EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD') DEFAULT_FROM_EMAIL = EMAIL_HOST_USER

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_USER_MARK_MOBILE_VERIFIED': True,
'PASSWORDLESS_USER_MOBILE_VERIFIED_FIELD_NAME': 'mobile_verified',
'PASSWORDLESS_USER_MARK_EMAIL_VERIFIED': True,
'PASSWORDLESS_USER_EMAIL_VERIFIED_FIELD_NAME': 'email_verified',

'PASSWORDLESS_EMAIL_TOKEN_HTML_TEMPLATE_NAME': "core/auth.html"

}

bigfat130397 commented 2 years ago

This is possible by mentioning a specific function in configuration, just replace the below value to your function name and it will work

'PASSWORDLESS_SMS_CALLBACK': 'drfpasswordless.utils.send_sms_with_callback_token'

for example in my project with app named testapp in views.py my customized function named send_sms_code then my value would be:

'PASSWORDLESS_SMS_CALLBACK': 'testapp.views.send_sms_code'

jaymes15 commented 2 years ago

@bigfat130397 answer is correct Tried and it works