Electron

Steps to integrate SAWO Web SDK in electron app

  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. Include sawo-electron.min.js to your source, follow either of following method 1. If you have Content Security Policy enabled, download the sawo-electron.min.js using following command and include it in your root source directory

    wget https://websdk.sawolabs.com/sawo-electron.min.js
    1. If you don't have Content Security Policy enabled, include sawo-electron.min.js in your source using

      <script src="https://websdk.sawolabs.com/sawo-electron.min.js"></script>
  5. Add the snippet at bottom of source inside body tag

    <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) => {
    console.log(payload)
    },
    };
    var sawo = new Sawo(config);
    sawo.showForm();
    </script>
  6. 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('http://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