HTML/Web

Getting Swoop up and running in only three lines of Javascript.

This guide will show you how to hook up Swoop Authentication to any button on your site, in just a few lines of code.

1. Add the Swoop JS to Your Page's Head

<script src="https://cdn.jsdelivr.net/npm/@swoop-password-free/[email protected]/dist/swoop.js"></script>

2. Initialize Swoop With Your Client ID

Make sure you've added a new app in your Swoop Dashboard.

<script>
  let swoop = new Swoop("swoop_4wtjd4k7nljf30");
</script>

3. Create an Authentication Function

<script>
	const authenticate = async () => {
   	let user = await swoop.in();
    console.log(user);
    // user.email
    // user.id_token
    // user.user_meta
    // Send user.id_token to your backend to complete authentication and log the user in
  }
</script>

4. Call the Authentication Function

<button onclick="authenticate()">Login</button>

And that's it! Your users are now in a password-free paradise.

πŸ“˜

Security Note

Once the user is authenticated, you should send the user.id_token to your server to be verified with your CLIENT SECRET to ensure the token is valid.