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 tokenOAuth 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 tokenSession Management
// Get current user
const user = client.auth().currentUser();
// Logout
await client.auth().logout();
// Logout all devices
await client.auth().logoutAll();