Getting Started with Onebase Authentication

Getting Started with Onebase Authentication

Onebase Team
15 months ago
5 min read
authsecuritytutorial

Getting Started with Onebase Authentication

Authentication is a crucial part of any modern application. Onebase provides a simple yet powerful authentication system that integrates seamlessly with your existing infrastructure.

Setting Up Authentication

To get started with Onebase authentication, you'll need to configure your application with the following code:

javascript
import { OnebaseAuth } from '@onebase/auth';

const auth = new OnebaseAuth({
  apiKey: 'your-api-key',
  domain: 'your-domain.onebase.com',
  redirectUri: 'http://localhost:3000/callback'
});

// Initialize authentication
auth.initialize().then(() => {
  console.log('Authentication initialized');
});

User Login

Once you have authentication set up, implementing user login is straightforward:

javascript
// Login with email and password
const loginUser = async (email, password) => {
  try {
    const user = await auth.login(email, password);
    console.log('User logged in:', user);
  } catch (error) {
    console.error('Login failed:', error);
  }
};

This approach ensures that your users have a secure and seamless authentication experience.

Related Articles