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.eyJpZCI6OCwiYXV0aFByb3ZpZGVySWRlbnRpZmllciI6ImVtYWlsIiwidXNlcklkZW50aWZpZXIiOiJ0ZXN0QHRlc3QucnUiLCJpYXQiOjE3Njc3NTkzNDgsImV4cCI6MTc2Nzc5NTM0OH0._Wrk4ZU1rmffbWN_mgBa_2K6yavC6O_-W1-XBPGtQtI",
"refreshToken": "1767759348540-5a2baaad-7364-4a1c-8b85-9d88404b9db9"
}

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"