Prerequisites
Before this page: have an embedded wallet (see Post-login user setup) and, if your project uses one, its password.What you’ll build
- Readiness — tell the user whether their wallet is ready to use or still locked behind a password.
- Back up — save the wallet’s key shares to the user’s Google Drive.
- Export — reveal the raw private key in a secure container, so a user can always self-custody.
Checking wallet readiness
getWalletRecoveryState doesn’t tell you whether a Google Drive backup exists — there’s no SDK call for that. It returns { walletReadyState, isPasswordEncrypted }: walletReadyState is WalletReadyState.READY once the wallet’s key material is available to sign with, or WalletReadyState.ENCRYPTED when it’s still locked behind a password. Use it to decide whether to prompt for the password (see Embedded wallet password & security) before letting the user sign or export.
- TypeScript
- React
Backing up to Google Drive
Backup uploads the wallet’s key shares to the user’s Google Drive, which needs two Drive scopes (GOOGLE_DRIVE_BACKUP_REQUIRED_SCOPES) granted on their linked Google account. getGoogleDriveBackupReadiness does the pre-flight: status is 'ready' when the scopes are already granted, or 'needs-access' when they aren’t.
You don’t assemble the scope list yourself — you request the scopes by sending the user back through Google sign-in. With Google Drive backup enabled in your project settings, signInWithSocialRedirect (web) automatically adds the required Drive scopes and forces a fresh consent screen. Once the scopes are granted, backupWaasKeySharesToGoogleDrive reuses the stored Google token, so you don’t pass an access token yourself.
- TypeScript
- React
signInWithSocialRedirect sends the user to Google and back, so finish the return with the standard redirect flow (detectSocialRedirectUrl + completeSocialRedirect) and then trigger the backup again — see Social OAuth sign-in & redirect handling for the full flow. On React Native, call signInWithSocialPopUp instead: it opens an in-app browser and resolves without leaving your screen.Pass the wallet
password to the backup call when your project protects wallets with a password — the backup is encrypted with it.Exporting the private key
For users who want to self-custody,exportWaasPrivateKey renders the key inside a secure display container you provide — an element the SDK controls so the key never touches your own DOM or app state.
- TypeScript
- React
Handling errors
See also
- Embedded wallet password & security — the password that encrypts the backup
- Social OAuth sign-in & redirect handling — how to obtain the Google access token with Drive scopes
- Post-login user setup — prompt for backup right after the wallet is created