> ## Documentation Index
> Fetch the complete documentation index at: https://docs.portalhq.io/llms.txt
> Use this file to discover all available pages before exploring further.

# configureGoogleStorage

> Configure Google Drive backup storage.

## Function Signature

```dart theme={null}
Future<void> configureGoogleStorage({
  required String clientId,
  PortalGDriveBackupOption backupOption =
      PortalGDriveBackupOption.customFolder,
  String? folderName,
  @Deprecated('Use folderName instead. Will be removed in the next minor.')
  String? applicationName,
  bool? signOutAfterUse,
  bool? useNewExperimentalGoogleAuthApi,
})
```

## Description

Configures Google Drive backup storage. Must be called before using `PortalBackupMethod.googleDrive` for backup or recovery. `backupOption` selects where the encrypted backup is written.

## Parameters

| Parameter                         | Type                       | Required | Description                                                                                                                                                            |
| --------------------------------- | -------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `clientId`                        | `String`                   | Yes      | Your Google OAuth client ID (from Google Cloud Console).                                                                                                               |
| `backupOption`                    | `PortalGDriveBackupOption` | No       | Where the encrypted backup is written. Defaults to `customFolder` for backward compatibility. **New integrations should pass `appDataFolder`.**                        |
| `folderName`                      | `String?`                  | No       | Folder name for `customFolder`. Defaults to `_PORTAL_MPC_DO_NOT_DELETE_`. Ignored for `appDataFolder` and `appDataFolderWithFallback`.                                 |
| `applicationName`                 | `String?`                  | No       | **Deprecated** — aliases `folderName` for one release. Migrate to `folderName`.                                                                                        |
| `signOutAfterUse`                 | `bool?`                    | No       | **Android only.** Signs the user out of Google after each backup / recovery operation. iOS ignores this flag.                                                          |
| `useNewExperimentalGoogleAuthApi` | `bool?`                    | No       | **Android only.** Opt into the new Credential Manager-based authentication flow. When `false` (default) the legacy `GoogleSignIn` flow is used. iOS ignores this flag. |

### PortalGDriveBackupOption

| Value                       | Description                                                                                                                                                                     |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `appDataFolder`             | Stores backups in the hidden, app-specific App Data Folder in Google Drive. This folder is not visible to the user.                                                             |
| `appDataFolderWithFallback` | Attempts to store backups and recover using the App Data Folder. If recovery fails, it automatically falls back to a user-visible Google Drive folder. `folderName` is ignored. |
| `customFolder`              | Stores backups in a user-visible folder named `folderName` (defaults to `_PORTAL_MPC_DO_NOT_DELETE_`).                                                                          |

## Returns

**`void`**

## Important Notes

* All three options are supported by the native iOS and Android SDK versions bundled with the current `portal_flutter` release. If you pin or override a lower native SDK version, `appDataFolder` and `appDataFolderWithFallback` may be rejected at runtime and backups previously stored in the App Data Folder will be lost — keep your `portal_flutter` dependency current to avoid this.
* Choose the appropriate `backupOption` based on your application's requirements:
  * Use `appDataFolder` to keep wallet backups hidden from users (recommended).
  * Use `customFolder` if you want users to see the backup file in their Drive UI.
  * Use `appDataFolderWithFallback` only when migrating an existing custom-folder integration.

## Example Usage

```dart theme={null}
// Example 1: Using App Data Folder (recommended)
await portal.configureGoogleStorage(
  clientId: 'your-google-client-id',
  backupOption: PortalGDriveBackupOption.appDataFolder,
);

// Example 2: Using visible folder with custom name
await portal.configureGoogleStorage(
  clientId: 'your-google-client-id',
  backupOption: PortalGDriveBackupOption.customFolder,
  folderName: 'MyAppBackups',
);

// Example 3: Using App Data Folder for backup and recover with fallback to GDrive folder if recover fails
await portal.configureGoogleStorage(
  clientId: 'your-google-client-id',
  backupOption: PortalGDriveBackupOption.appDataFolderWithFallback,
);
```

## Errors

Throws a `PortalException` on failure:

| Code                     | Description                                                                                                                                                                                              |
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `NOT_INITIALIZED`        | Portal was not initialized. Call `initialize()` first.                                                                                                                                                   |
| `CONFIGURE_GDRIVE_ERROR` | Native SDK failed to configure Google Drive (e.g. unable to resolve a presenting view on iOS, invalid OAuth client ID, missing Google Play services on Android). Inspect `e.message` for the diagnostic. |

## Related Documentation

For more information about Google Drive integration, see:

* [Configure GDrive storage](../../../resources/backup-options/gdrive)
* [Google Drive Backup Method](../guide/back-up-a-wallet)
