B2H BaaS

Authentication

B2H BaaS provides built-in authentication with email/password and OAuth providers.

Email/Password Authentication

// Register a new user
const user = await client.auth().register({
  email: 'user@example.com',
  password: 'securePassword123'
});

// Login
const session = await client.auth().login({
  email: 'user@example.com',
  password: 'securePassword123'
});

console.log(session.token); // JWT token

OAuth Providers

Supported providers: Google, Microsoft, Facebook

// OAuth login (frontend)
await client.auth().loginWithOAuth('google');

// The user will be redirected to the OAuth provider
// After login, they are redirected back with a token

Session Management

// Get current user
const user = client.auth().currentUser();

// Logout
await client.auth().logout();

// Logout all devices
await client.auth().logoutAll();