EML Docs

AzAuth

AzAuth authenticates players using their account on an Azuriom website. It requires the Auth API plugin to be enabled in Azuriom’s admin panel.

Warning

You must verify the player’s access token server-side when they connect to your Minecraft server. See the verify endpoint in the Azuriom Auth API documentation.

import { AzAuth } from 'eml-lib'

authUser()

async function authUser() {
  const auth = new AzAuth('https://myserver.com')

  try {
    const account = await auth.auth('GoldFrite', 'MyPassword123')
    // store account and proceed to the home view
  } catch (err) {
    if (err.code === 'TWOFA_CODE_REQUIRED') {
      const account = await auth.auth('GoldFrite', 'MyPassword123', '123456')
      // store account and proceed to the home view
    } else {
      console.error(err)
    }
  }
}

Constructor

ParameterTypeDescriptionRequired?
urlstringThe base URL of your Azuriom website.Yes

auth() method

Authenticates a player with their Azuriom credentials.

ParameterTypeDescriptionRequired?
usernamestringThe player’s username or email.Yes
passwordstringThe player’s password.Yes
twoFACodestringThe two-factor authentication code.No

Returns: Promise<Account>

Throws: TWOFA_CODE_REQUIRED — If two-factor authentication is enabled and no code was provided. • AUTH_ERROR — If authentication fails.

verify() method

Verifies that an existing account’s token is still valid against the Azuriom server.

ParameterTypeDescriptionRequired?
userAccountThe account to verify.Yes

Returns: Promise<Account> — The account with refreshed data.

Throws: AUTH_ERROR — If verification fails.

logout() method

Logs out a player from Azuriom.

ParameterTypeDescriptionRequired?
userAccountThe account to log out.Yes

Returns: Promise<void>

Throws: AUTH_ERROR — If the logout fails.