Skip to main content

auth

Allows you to authenticate users.

Description

This method performs user authorization. It returns a Promise that resolves to an IAuthEntity object.

AuthProvider.auth(

marker*, body*

);

Parameters schema

Schema

marker(required): string
The text identifier of the authorization provider
example: "email"

body(required): IAuthPostBody
Objects contains auth information
example:

{
"authData": [
{
"marker": "login",
"value": "example@oneentry.cloud"
},
{
"marker": "password",
"value": "12345"
}
]
}

body.authData any[]
Authorization data taken from the form attached to the authorization provider
example: ""

[
{
"marker": "login",
"value": "example@oneentry.cloud"
},
{
"marker": "password",
"value": "12345"
}
]

body.authData[index].marker string
Registration form login attribute marker
example: "example@oneentry.cloud"

body.authData[index].value string
Registration form login attribute value
example: "12345"

Examples

Minimal example


const body = {
"authData": [
{
"marker": "login",
"value": "example@oneentry.cloud"
},
{
"marker": "password",
"value":"12345"
}
]
};

const response = await AuthProvider.auth('email', body);

Example response

{
"userIdentifier": "test@test.ru",
"authProviderIdentifier": "email",
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6OCwiYXV0aFByb3ZpZGVySWRlbnRpZmllciI6ImVtYWlsIiwidXNlcklkZW50aWZpZXIiOiJ0ZXN0QHRlc3QucnUiLCJpYXQiOjE3NjI0MjEyNzYsImV4cCI6MTc2MjQ1NzI3Nn0.TR3Hjud_cUWR_fHyy6e_f6qs7j42-yz0cgxvLZ0ZNBI",
"refreshToken": "1762421276286-93950574-bd0b-4a50-9cf5-8e5107d27b38"
}

Response schema

Schema: IAuthEntity

userIdentifier: string
The unique identifier for the user.
example: "user12345"

authProviderIdentifier: string
The identifier for the authentication provider.
example: "email"

accessToken: string
The access token for the user session.
example: "abcdef123456"

refreshToken: string
The refresh token for renewing the access token.
example: "ghijkl789012"