# Python

You can find out the Python auth APIs public repo [here](https://github.com/crema-git/crema-python-flask.git)

All Auth APIs listed here -

## Register User

<mark style="color:green;">`POST`</mark> `https://www.your-domain.com/api/v1/users`

This API is used for the register user

#### Request Body

| Name                                       | Type   | Description              |
| ------------------------------------------ | ------ | ------------------------ |
| name<mark style="color:red;">\*</mark>     | String | Name of the user         |
| email<mark style="color:red;">\*</mark>    | String | Name of the user         |
| password<mark style="color:red;">\*</mark> | String | Password for the account |

{% tabs %}
{% tab title="200: OK User registered sucessfully" %}

```javascript
{
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2MDA1Nzc5MTIsIm5iZiI6MTYwMDU3NzkxMiwianRpIjoiNzg0OWQyOWMtZjlkNC00ZDRlLWEwMjAtMjkzMTcxNzE5MmVkIiwiZXhwIjoxNjAwNTc4ODEyLCJpZGVudGl0eSI6MSwiZnJlc2giOnRydWUsInR5cGUiOiJhY2Nlc3MifQ.Cx76YDyMWVVCb2gQPhQ4JejeQjY8_gbD2RTOZv4ZDHI",
    "refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2MDA1Nzc5MTIsIm5iZiI6MTYwMDU3NzkxMiwianRpIjoiYWY4NTQ4NWMtZTUwZi00NWJkLWJkNTEtYzJjNTg3MDAzMGUwIiwiZXhwIjoxNjAzMTY5OTEyLCJpZGVudGl0eSI6MSwidHlwZSI6InJlZnJlc2gifQ.XXLZ7tAYuZDqfYvWZ9pX4EdNbQLfnlEclXWMaewOD3U"
}
```

{% endtab %}

{% tab title="400: Bad Request User registration failed " %}

```javascript
{
    "error": "A user with that email already exists."
}
```

{% endtab %}
{% endtabs %}

## Login User

<mark style="color:green;">`POST`</mark> `https://www.your-domain.com/api/v1/auth`

This API is used for the login user

#### Request Body

| Name                                       | Type   | Description             |
| ------------------------------------------ | ------ | ----------------------- |
| name<mark style="color:red;">\*</mark>     | String | Email of the user       |
| password<mark style="color:red;">\*</mark> | String | Password of the account |

{% tabs %}
{% tab title="200: OK Login user" %}

```javascript
{
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2MDA1NzgwNDksIm5iZiI6MTYwMDU3ODA0OSwianRpIjoiYjIxNDNkMjUtOWI3Yi00Y2FlLThmN2YtY2YxZDQyNzVhMTUwIiwiZXhwIjoxNjAwNTc4OTQ5LCJpZGVudGl0eSI6MSwiZnJlc2giOnRydWUsInR5cGUiOiJhY2Nlc3MifQ.IWnfR_2UFSJtzWHqzTG5o7PnHd3H6cQc13bnwe8cPPU",
    "refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2MDA1NzgwNDksIm5iZiI6MTYwMDU3ODA0OSwianRpIjoiOThmNzQzZDMtN2M2Mi00ODFjLThjOWItMjI3NTQyZDljNTg3IiwiZXhwIjoxNjAzMTcwMDQ5LCJpZGVudGl0eSI6MSwidHlwZSI6InJlZnJlc2gifQ.g8UV9xSxHzc3XxgIzY0CTm2_2RTjTY2bn484gFdsW0E"
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

```javascript
{
    "error": "Invalid credentials!"
}
```

{% endtab %}
{% endtabs %}

## Auth User

<mark style="color:blue;">`GET`</mark> `https://www.your-domain.com/api/v1/auth`

This API is used to check the auth token validation

#### Headers

| Name                                            | Type   | Description  |
| ----------------------------------------------- | ------ | ------------ |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer token |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "created_on": "2020-09-20T04:58:32",
    "id": 1,
    "email": "jose@gail.com",
    "email_verified_at": null,
    "updated_on": "2020-09-20T04:58:32",
    "name": "jose"
}
```

{% endtab %}
{% endtabs %}
