Skip to main content

Getting Started

Installing​

You can install aircampi's auth via NPM, Yarn or CDN.

NPM:

  npm install @aircampi/auth

Yarn:

  yarn add @aircampi/auth

CDN:

  <script src="https://cdn.jsdelivr.net/npm/@aircampi/auth"/>

//or

<script src="https://unpkg.com/@aircampi/auth"/>

Find the source code on GitHub.

Initializing​

There are 2 way to initialize new client.

Using createClient():


import { createClient } from '@aircampi/auth'

// Create a client for interacting with your auth stack

const auth = createClient({
domain: '<YOUR_DOMAIN>',
client_id: '<YOUR_CLIENT_ID>'
})

Using AuthClient object


import { Client } from '@aircampi/auth';

const auth = new Client({
domain: '<YOUR_DOMAIN>',
client_id: '<YOUR_CLIENT_ID>'
});

//if you do this, you'll need to check the session yourself

try {
await auth.getToken();
} catch (error) {
if (error.error !== 'login_required') {
throw error;
}
}