Skip to main content

Authentication

Authenticating users#

https://{app-id}.essentialz.cloud/authenticate

Apple#

Prerequisites#

Create Apple app.

TBD

Authentication#

/authenticate#

In order to authenticate user using Google you need to provide identity_token alongside provider name inside the body of your POST request. For this particular scenario provider name should be set to apple

Authentication request object
{
"identity_token": "XXXXXXXXXXXX",
"provider": "apple"
}
Authentication response object
{
"id": 1,
"role": "regular",
"apple_id": "YYYYYYYYYY",
"active": true,
"details": {},
"authorization": {
"token": "eyJhbGc...."
}
}

Further requests to the API should use Bearer authorization as follows.

const headers = new Headers();
headers.append("Authorization", "Bearer {{token}}");

Email & Password#

Prerequisites#

Before you can use email based authentication, user must be created inside the Essentialz Architect's db through sign up process.

Create User
const headers = new Headers();
headers.append("Content-Type", "application/json");
const raw = JSON.stringify({
email: "user@demo.com",
password: "strongPassWord",
});
const requestOptions = {
method: "POST",
headers: headers,
body: raw,
redirect: "follow",
};
fetch("https://your_app_id.essentialz.cloud/users", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));

Authentication#

/authenticate#

In order to authenticate user using email and password you need to provide both email and password alongside provider name inside the body of your POST request. For this particular scenario provider name should be set to email

Authentication request object
{
"email": "user@demo.com",
"password": "strongPassWord",
"provider": "email"
}
Authentication response object
{
"id": 1,
"email": "user@demo.com",
"role": "regular",
"active": true,
"details": {},
"authorization": {
"token": "eyJhbGc...."
}
}

Further requests to the API should use Bearer authorization as follows.

const headers = new Headers();
headers.append("Authorization", "Bearer {{token}}");

Facebook#

Prerequisites#

Create FB app.

TBD

Authentication#

/authenticate#

In order to authenticate user using Facebook you need to provide access_token alongside provider name inside the body of your POST request. For this particular scenario provider name should be set to facebook

Authentication request object
{
"access_token": "XXXXXXXXXXXX",
"provider": "facebook"
}
Authentication response object
{
"id": 1,
"role": "regular",
"facebook_id": "YYYYYYYYYY",
"active": true,
"details": {},
"authorization": {
"token": "eyJhbGc...."
}
}

Further requests to the API should use Bearer authorization as follows.

const headers = new Headers();
headers.append("Authorization", "Bearer {{token}}");

Google#

Prerequisites#

Create Google app.

TBD

Authentication#

/authenticate#

In order to authenticate user using Google you need to provide id_token alongside provider name inside the body of your POST request. For this particular scenario provider name should be set to google

Authentication request object
{
"id_token": "XXXXXXXXXXXX",
"provider": "google"
}
Authentication response object
{
"id": 1,
"role": "regular",
"google_id": "YYYYYYYYYY",
"active": true,
"details": {},
"authorization": {
"token": "eyJhbGc...."
}
}

Further requests to the API should use Bearer authorization as follows.

const headers = new Headers();
headers.append("Authorization", "Bearer {{token}}");