Web-SDK Integration

Steps to integrate SAWO authentication on your web application
  1. Login to sawo dev console - dev.sawolabs.com

  2. Create a new project and copy the API key

  3. On your source, create a container for sawo component inside body tag

<div id="sawo-container" style="height: 300px; width: 300px;"></div>

4. Add the snippet at bottom of source inside body tag

<script src="https://websdk.sawolabs.com/sawo.min.js"></script>
var config = {
// should be same as the id of the container created on 3rd step
containerID: "sawo-container",
// can be one of 'email' or 'phone_number_sms'
identifierType: "phone_number_sms",
// Add the API key copied from 2nd step
apiKey: "",
// Add a callback here to handle the payload sent by sdk
onSuccess: (payload) => {
var sawo = new Sawo(config);

5. Recommended: Verify the payload sent by SDK from your backend:

Python example:

import requests
data = {
'user_id': payload_sent_from_sdk['user_id']
res = requests.post('https://api.sawolabs.com/api/v1/userverify/', data=data)
# Match the verification token in response with sdk payload
if res.status_code == 200:
response_data = res.json()
if response_data['verification_token'] \
== payload_sent_from_sdk['verification_token']:
# continue with your implementation for example add the user to your db