Arcana Auth
Arcana SDK to perform logins on your app.
Installation
Using NPM/Yarn
npm install --save @arcana/auth
yarn add @arcana/auth
Using built source
<script src="<path-to>/auth.js"></script>
Initialise the SDK
const { AuthProvider } = window.arcana.auth;
import { AuthProvider } from '@arcana/auth';
const auth = new AuthProvider({
appID: <appID>,
redirectUri:'',
oauthCreds: [{
type: 'google',
clientID: '',
},
{
type: 'twitter',
clientID: '',
},
{
type: 'github',
clientID: '',
},
{
type: 'discord',
clientID: '',
}]
})
On redirect Page
const { AuthProvider } = window.arcana.auth;
import { AuthProvider } from '@arcana/auth';
window.onload = () => {
AuthProvider.handleRedirectPage(<origin>);
};
Initiate login
await auth.loginWithSocial(<loginType>);
Get user info
const userInfo = auth.getUserInfo();
Get public key
const userInfo = await auth.getPublicKey({
verifier: <loginType>,
id: <email | username>,
});
Check if user already logged in
const loggedIn = auth.isLoggedIn();
if (!loggedIn) {
await auth.loginWithSocial(<loginType>);
}
const userInfo = auth.getUserInfo()
Clear login session
await auth.logout();
Variables
loginType
- discord, twitter, github, google, twitch, redditorigin
- Base url of your app.