Flask is a micro web framework written in Python. It is classified as a micro framework because it does not require particular tools or libraries.

Let's Get your Flask App running with SAWO


Python, pip (package-management system written in Python used to install and manage software packages)


1. The first step to getting started with SAWO API integration into your Django website/application is to install the sawo package as given below:
pip install sawo
2. Next, you have to import createTemplate, getContext, and verifyToken methods from Sawo. The getContext method is used to create sawo dictionary object from data gain from Django Database. The ways to create the template and verify the token are given in subsequent steps.
from sawo import createTemplate, getContext, verifyToken
3. To use SAWO Login you would need an API key which can be obtained by creating a project in the sawo dashboard.
4. Once you create your project, you would need to set your project name and hostname. 4.1. For development in a local machine, the hostname should be set to 'localhost'.
If using ''localhost" as hostname is not working for you, try ""
4.2. For production, the hostname should be set to your domain.
If you are adding your domain do not add 'https://', ''http://', 'www' or even trailing backslash. Example: should be kept as
5. Copy the API key from the project and keep it safe and secure.
The best practice to store your API key is to store values in .env so that they are not exposed.
6. Getting Started with the Setup in Flask:
  • First, you have to create a template for SAWO password-less and OTP-less Authentication for your Flask website. Use the code given below for the same:
  • Next, you have to send this data required by _sawo.html. The variable names used in _sawo.html template are sawo.auth_key, sawo.identifier and Therefore,to send this data you have to create a JSON.
Note: The "to" route should be a post route that can receive posted data. If you don’t know how data is passed to templates in Django or Flask. We will suggest looking into it first
  • Creating fields for sawo api_key and identifier to set it from admin dashboard. Copy this code in models of your app
class Config(models.Models):
api_key = models.CharField(max_length=200)
identifier = models.CharField(max_length=200)
choices = [("email","Email"),("phone_number_sms","Phone")]
  • Setting up of the app. Note: Route should be the receiving end where you can handle post request
from models import Config
from sawo import getContext
def <your_function>(request):
config = Config.objects.order_by('-api_key')[:1]
context = {
"sawo" = getContext(config,<route>) #the route where you will recieve
the payload sent by sdk
def index(request):
config = Config.objects.order_by('-api_key')[:1]
context = {
"sawo" = getContext(config,"login")
"auth_key": "<api_key>",
"identifier": "email | phone_number_sms"
"to": <route> #the route where you will recieve the payload sent by sdk
"auth_key": "785ha-hdjsdsd-799-ss345",
"identifier": "email | phone_number_sms"
"to": login
Once the SAWO SDK is successfully set up, a login form will be rendered in the provided container as displayed in the picture below:
Final Render of SAWO Login
Congratulations !! The SAWO API is now ready to be used in your Flask application 🤘.

You can also check out SAWO's
Flask Sample Code and Deployed App.

It's okay, we get it! You got Stuck!
Feel free to contact us on #ask-for-help on our Discord