Authenticate a User

Prompt login with a prebuilt modal (Recommended)

Open a prebuilt modal to prompt the user to sign in with email or social login.

await sdk.auth.loginWithPaperModal();
Prompt the user's email.

Prompt the user's email.

The user quickly verifies their email by providing a 6-digit code.

The user provides the 6-digit code sent to their inbox.

If the user is already logged in, this modal is skipped and the method returns.

This method throws an exception if the user closes the modal.

Reference: auth.loginWithPaperModal

Prompt email one-time passcode (OTP) modal (Advanced)

If the user's email is already known, email them a one-time passcode emailed and prompt them to verify it.

await sdk.auth.loginWithPaperEmailOtp({ email: "[email protected]" });

If the user is already logged in, this modal is skipped and the method returns.

Reference: auth.loginWithPaperEmailOtp

Prompt email one-time passcode (OTP) with your own UX (Advanced)

Control when and how to email and verify the user's OTP with headless methods.

const email = '...'; // Prompt the user's email

// Send the email an OTP.
const { isNewUser, isNewDevice } = await sdk.auth.sendPaperEmailLoginOtp({

const otp = '...'; // Prompt the user for the OTP.

// Verify the OTP code.
if (isNewUser || !isNewDevice) {
  await sdk.auth.verifyPaperEmailLoginOtp({
} else {
  // The recovery code is needed for returning users on a new device (isNewUser = false && isNewDevice = true).
  // Either prompt users for it or retrieve it from the backend
	const recovery '...'; 
  // Note that you only have to do this if you have the recoveryShareManagement set to USER_MANAGED
  await sdk.auth.verifyPaperEmailLoginOtp({

Reference: auth.sendPaperEmailLoginOtp, auth.verifyPaperEmailLoginOtp

Bring your own authentication with Custom JWT (Advanced)

To log in to your own custom authentication, call loginWithJwtAuth with the user's auth JWT after they have authenticated.

await sdk.auth.loginWithJwtAuth({
  token: "<token from your auth callback>",
  authProvider: AuthProvider.CUSTOM_JWT,
  recoveryCode: "Required if user is an existing user"

Reference: auth.loginWithJwtAuth

Log out

When a user logs out, they will be prompted to authenticate again. They will not be prompted to provide a recovery password again on this device.

await sdk.auth.logout()

Reference: auth.logout

Get a user's auth and wallet information

Check if a user is logged in and if so, get their auth details, wallet address, and wallet.

import { UserStatus } from "@paperxyz/embedded-wallet-service-sdk";

const result = await sdk.getUser();
switch (result.status) {
  case UserStatus.LOGGED_OUT: {
    // User is logged out.
    // Call `sdk.auth.loginWithPaperModal()` to log the user in.
    // User is logged in.
    const { authDetails, walletAddress, wallet } = result.user;

Reference: getUser