Login

Login #

The Login endpoint authenticates an email/password pair and returns a bearer access token that is valid for 24 hours.

Caution
The access token grants the authenticated user access to all features and functions of the API. The token should therefore be treated as a secret and not shared.

Request #

curl --location --request POST 'https://api.microbooks.io/auth/v1/login' \
--data-raw '{
    "email": "john.doe@example.com",
    "password": "securepassword"
}'
import requests

url = "https://api.microbooks.io/auth/v1/login"
body = {"email": "john.doe@example.com", "password": "securepassword"}
headers = {}

response = requests.request("POST", url, headers=headers, json=body)

print(response.text)
var request = require('request');
var options = {
    'method': 'POST',
    'url': 'https://api.microbooks.io/auth/v1/login',
    'headers': {},
    'body': '{
        "email": "john.doe@example.com",
        "password": "securepassword"
    }'
};
request(options, function (error, response) {
    if (error) throw new Error(error);
    console.log(response.body);
});

$client = new Client();
$body = '{
    "email": "john.doe@example.com",
    "password": "securepassword"
}';
$request = new Request('POST', 'https://api.microbooks.io/auth/v1/login', 
    [], 
    $body
);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
var client = new RestClient("https://api.microbooks.io/auth/v1/login");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
var body = "{ 
    \"email\": \"john.doe@example.com\", 
    \"password\": \"securepassword\"
}";
request.AddParameter("text/plain", body,  ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

Response #

{
    "user": {
        "id": 1,
        "name": "John Doe",
        "email": "john.doe@example.com"
    },
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOi8vYXBpLm1pY3JvYm9va3MuaW8vYXV0aC92MS9sb2dpbiIsImlhdCI6MTY2NzUwNDU1MiwiZXhwIjoxNjY3NTA4MTUyLCJuYmYiOjE2Njc1MDQ1NTIsImp0aSI6IjI0WWpTZTk1QWNDSlRnRFYiLCJzdWIiOiIxIiwicHJ2IjoiYzhlZTFmYzg5ZTc3NWVjNGM3Mzg2NjdlNWJlMTdhNTkwYjZkNDBmYyJ9.lIw7A7GRFzQO8vSPmARg4SAdL9U2qd3KY3Yzg5g_Ypg",
    "token_type": "bearer",
    "expires_in": 86400
}