VanillaJS
This guide explains how to set up your Vanilla javascript project to begin using @badisi/auth-js.
Make sure you properly configured your 👉 Authentication Provider.
Installation​
-
Install the library from the NPM repository
- npm
- yarn
npm install @badisi/auth-js --saveyarn add @badisi/auth-js -
Copy required files to your application assets folder
{
"glob": "**/*",
"input": "node_modules/@badisi/auth-js/oidc/assets",
"output": "oidc/callback"
}infoAssets needs to be copy over to your application because some html web pages are used and required when navigating back from the Authentication Provider.
-
Provide the library in your main entrypoint
main.tsimport { initOidc } from '@badisi/auth-js/oidc';
initOidc({
authorityUrl: 'https://dev-fijd1e9x.us.auth0.com',
clientId: 'kRVVEnAWKMpxxpcodl0TqLXfIHgQvmmt'
}).then(manager => {
// Expose the manager for later use (if needed)
window.authManager = manager;
// Bootstrap your application
document.body.appendChild(document.createElement('app-root'));
}).catch(error => console.error(error));infoInitializing the library prior to your application bootstrapping ensures that all the security checks are made upstream (if needed) and avoid the whole application to be loaded twice when using redirects.
tipFor more info on how to configure the library please have a look at the
configurationpage. -
You're done! 🚀