Package: sawo
SawoPasswordless and OTP-less Authentication for your website.Check the documentaion here.InstallingA step by step series of examples that tell you how to get a development env running. These instructions will let you render the form in your speicified container, and allow you to attach successful login callback for futher actions.Install the sawo packagepip install sawoImport from Sawo createTemplate, getContext and verifyToken method from the sawo packageThe getContext method is used to create sawo dict object from data gain from DB in DjangofromsawoimportcreateTemplate,getContext,verifyTokenAPI KeyLogin to sawodev consoleCreate a new projectSet Project NameSet Project HostFor dev: point to localhostFor prod: point to your domain.Copy the API keySetupGetting started Creating template for sawo passwordless and OTP-less Authentication for your website.DjangocreateTemplate("<filepath>")#examplecreateTemplate("templates/partials")FlaskcreateTemplate("./<filepath>",flask=True)#examplecreateTemplate("./templates/partials",flask=True)This will create a _sawo.html file in the filepath provided.Using _sawo.html in your html filesDjango{% include "<filepath>/_sawo.html" %}

    #example
    {% include "partials/_sawo.html" %}Flask{% include "./<filepath>/_sawo.html" %}

    #example
    {% include "./partials/_sawo.html" %}Sending data required by _sawo.htmlThe variable name used in_sawo.htmltemplate aresawo.auth_key,sawo.identifierandsawo.toso to send that data we create a json.NoteThe "to" route should be a post route which can recive posted dataIf you dont know how data is passed to templates in Django or Flask, We will suggest looking into it first.DjangoMethod 1. Sending static datacontext={"sawo":{"auth_key":"<api_key>","identifier":"email | phone_number_sms","to":"<route>"#the route where you will recive the payload sent by sdk}}#exapmplecontext={"sawo":{"auth_key":"785ha-hdjsdsd-799-ss345","identifier":"phone_number_sms","to":"login"}}Method 2. Using admin and database to save config for sawoStep 1. Creating fields for sawo api_key and identifier to set it from admin dashboardcopy this code in models of your appclassConfig(models.Model):api_key=models.CharField(max_length=200)identifier=models.CharField(max_length=100,choices=[("email","Email"),("phone_number_sms","Phone")])Step 2. Setting up view.py of appNote: Route should be the reciving end where you can handle post requestfrom.modelsimportConfigfromsawoimportgetContextdef<yourfuntion>(request):config=Config.objects.order_by('-api_key')[:1]context={"sawo":getContext(config,<route>)#the route where you will recive the payload sent by sdk}#exampledefindex(request):config=Config.objects.order_by('-api_key')[:1]context={"sawo":getContext(config,"login")}Flasksawo={"auth_key":"<api_key>","identifier":"email | phone_number_sms","to":"<route>"#the route where you will recive the payload sent by sdk}#exapmplesawo={"auth_key":"785ha-hdjsdsd-799-ss345","identifier":"phone_number_sms","to":"login"}Verifying TokenWhen he login is done on the webpage it sends the data to backend as payload to verify user you can use verifyToken function , it returns a boolen.BackendCode is ame for Django and FlaskfromsawoimportverifyTokenverifyToken()#use the methods provided by flask and django to recive data from post request#then use this funtion it will return True or False depending on user statusForExample(Thedatakeypairisanexamplebelow,thesekeysarereturnedinpayloadoncetheuserisauthenticatedfromSAWO)data={"user_id":"a0aca1a0-7460-4e8e-8e46-3baf2c92423d","verification_token":"ADdHrvkgi407qNfnAyrIVqokm3OWdKUCdj8y"}if(verifyToken(data)):#do somethingelse:#do something elseTutorialsDjango Tutorial-See TutorialFlask Tutorial-See TutorialVersioningWe useSemVerfor versioning.AuthorsSAWO Labs-GitHubLicenseThis project is licensed under the MIT License