Aller au contenu principal

Authentication & Token Management

Description

The authentication system in Liberty Framework uses an access token mechanism. A user provides their credentials, and if authenticated, they receive an access token.

Data Structure

Successful Response

Field NameTypeDescription
access_tokenstringThe generated token for the session.
token_typestringType of token, usually "bearer".
status"success"Indicates authentication was successful.
messagestringMessage confirming login success.

Failed Response (Login Error)

Field NameTypeDescription
access_tokenstringEmpty, as login failed.
token_typestringType of token, usually "bearer".
status"failed"Indicates authentication failure.
messagestringError message "loginError".

Failed Response (Password Error)

Field NameTypeDescription
access_tokenstringEmpty, as authentication failed.
token_typestringType of token, usually "bearer".
status"failed"Indicates authentication failure.
messagestringError message "passwordError".

Example Usage

import { getToken } from "@nomana-it/liberty-core"

export const AuthenticationExample = async () => {
const response = await getToken("admin", "admin");

if (response.status === "success") {
console.log("Access Token:", response.access_token);
} else {
console.error("Authentication Failed:", response.message);
}
};

🔗 GitHub Repository (Core): Liberty Core
🔗 GitHub Repository (Test Project): Liberty Test
📖 Live Documentation: Liberty Core Docs
💖 Sponsor & Support: Sponsor Liberty Core