✨Works out of the box guarantee. If you face any issue at all, hit us up on Telegram and we will write the integration for you.

OAuth Javascript
Quickstart

Quick Start Guide

Get up and running with Reclaim Auth JavaScript in your application quickly.

Create Your Application

  1. Go to the Reclaim Identity Dashboard (opens in a new tab)

  2. Click on "Create New Application"

  3. Fill in your application details:

    • Basic Information: Enter the basic details of your application.
    • Identity Providers: Select the identity providers you want to include in your application. You can think of identity providers as ways to identify the user, for example if you include Google as a provider the user will be asked to login with google in the first screen of the auth pop-up.
    • Additional Providers: You can request additional data from the user, the user will be asked to generate a proof for each of the selected additional providers.
    • Redirect URIs: Add your application domain (required for security validation)
      • For local development: http://localhost:3000
      • For production: https://yourdomain.com
  4. Click "Create Application" and save your credentials:

    • Note your Application ID (this will be your clientId)
    • Note your Application Secret (this will be you clientSecret)

Dashboard Application Creation

Installation

Using NPM

npm install @reclaim/identity-js

Using CDN

<script src="https://unpkg.com/reclaim-identity-js@latest"></script>

Basic Implementation

<!DOCTYPE html>
<html>
<head>
    <title>Reclaim Auth Demo</title>
</head>
<body>
    <button id="loginBtn">Sign In</button>
    <div id="userInfo"></div>
 
    <script src="https://unpkg.com/reclaim-identity-js@latest"></script>
    <script>
        const auth = getReclaimAuth(
            'your-client-id',
            'http://localhost:3000'  // Must match dashboard configuration
        );
 
        // Handle auth state changes
        auth.onAuthStateChanged(user => {
            const userInfo = document.getElementById('userInfo');
            if (user) {
                userInfo.textContent = JSON.stringify(user, null, 2);
            } else {
                userInfo.textContent = 'No user signed in';
            }
        });
 
        // Handle sign in
        document.getElementById('loginBtn').onclick = async () => {
            try {
                const user = await auth.signIn();
                console.log('Signed in:', user);
            } catch (error) {
                console.error('Sign in failed:', error);
            }
        };
    </script>
</body>
</html>

Auth Flow

  1. User clicks the sign-in button
  2. A popup window opens with the authentication flow
  3. User completes authentication in the popup
  4. Popup automatically closes
  5. Main application receives the authentication result
  6. User session is established

Testing Your Integration

  1. Host your HTML file (using a local server for development):
npx serve .
  1. Open your browser to the local server URL (typically http://localhost:3000)

  2. Click the "Sign In" button

  3. Complete the authentication in the popup window

Common Issues

Popup Blocked

If the authentication popup is blocked:

  • Ensure popups are enabled for your domain
  • Sign-in must be triggered by a user action (click)
  • Check browser console for popup blocker warnings

CORS Issues

If you're getting CORS errors:

  • Verify your domain is properly configured in the dashboard
  • Check that you're using the correct environment URLs

Next Steps