sawopy 0.1.6
Sawo Project
License: MIT

# Sawo

Passwordless and OTP-less Authentication for your website. [Check the documentaion here.](https://docs.sawolabs.com/sawo/v/0.0.2/)

## Installing

A 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 package

```
pip install sawopy
```
#### Import the Sawo class and verifyToken method from the sawo package
```python
from sawo import createTemplate,verifyToken
```

#### API Key
* Login to sawo [dev console.](dev.sawolabs.com)
* Create a new project
    * Set Project Name
    * Set Project Host
        *  For dev: point to localhost
        *  For prod: point to your domain.
*  Copy the API key

#### Setup
Getting started Creating template for sawo passwordless and OTP-less Authentication for your website.

###### Django
```python
    createTemplate("<filepath>")

    //example
    createTemplate("templates/partials")
```
###### Flask
```python
    createTemplate("./<filepath>",flask=True)

    //example
    createTemplate("./templates/partials",flask=True)
```

This will create a _sawo.html file in the filepath provided.

##### Using _sawo.html in your html files


###### Django

```html
    {% include "<filepath>/_sawo.html" %}

    //example
    {% include "partials/_sawo.html" %}
```

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

    //example
    {% include "./partials/_sawo.html" %}
```


##### Sending data required by _sawo.html
The variable name used in _sawo.html template are sawo.auth_key,sawo.identifier and sawo.to so to send that data we create a json.

**Note**
1. The "to" toute should be a post route which can recive posted data
2. FI you dont know how dta is passed to templates in Django and Flask, We will suggest looking for it first. 

###### For Django
```python
    context = {"sawo": {
                "auth_key" : "your api key",
                "identifier":"email or phone_number_sms",
                "to":"the route where you will recive the payload sent by sdk" 
                }
            }

    //exapmple
    context = {"sawo": {
                "auth_key" : "785ha-hdjsdsd-799-ss",
                "identifier":"phone_number_sms",
                "to":"login" 
                }
            }
```

###### For Falsk
```python
    sawo = {
            "auth_key" : "your api key",
            "identifier":"email or phone_number_sms",
            "to":"the route where you will recive the payload sent by sdk" 
        }

    //exapmple
    sawo = {
            "auth_key" : "785ha-hdjsdsd-799-ss",
            "identifier":"phone_number_sms",
            "to":"login"
        }
```
#### Verifying Token
When he login is done on the webpage it sends the dat to backend as payload to verify user you can use verifyToken function , it returns a boolen.

```python
    #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 status
    verifyToken(payload)

    //example
    payload = <data from POST request>
    if(verifyToken(payload)):
        #do somthing
    else:
        #do somthing else
```

## Versioning
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags). 

## Authors
* **Om Praksh Vyas** - *Initial work* - [GitHub](https://github.com/ovyas24)

## License

This project is licensed under the MIT License