Let users login via text

You can manually send a text login to let users login to your website. Here's how to do it in python as an example:

import requests as req

client_id = 'YOUR CLIENT ID'
url = 'https://api.weasl.in/end_users/sms/send'
payload = { 'phone_number': '5555555555' }

res = request.post(url, payload, headers=header)
print(res.json())
# { "message": "token successfully sent" }

This will send a text message to the given phone number with a code that can be used to login. This code expires after 1 hour by default.

If you are on a paid plan, this request counts as a "login attempt" towards your plan quota

Once the user received the text message, the code can be verified with this endpoint:

import requests as req

client_id = 'YOUR CLIENT ID'
url = 'https://api.weasl.in/end_users/sms/verify'
payload = { 'token_string': '111111' }

res = request.post(url, payload, headers=header)
print(res.json())
# { "JWT": "a very long string" }

The endpoint, if successful, returns a JSON Web Token (JWT). The JavaScript embed for Weasl takes this value and stores it on your website as the cookie value. This value is what should be used as the Authorization header value in requests you send to Weasl's API on the user's behalf.


Did this help answer your question?

thumbs up
thumbs down

Thanks for the feedback! 🙏🏽


Help by drift