# Google Drive

:::tip Available
This integration is active and ready to use in Frihet.
:::

Connect your Google Drive to Frihet. List, search, upload, and download files directly from your ERP. Store invoices and documents in organized folders without leaving Frihet.

## What it does

With Google Drive connected:

- **List files** — View your Drive files and folders from Frihet
- **Search documents** — Find files by name or content
- **Upload files** — Save invoices, quotes, and documents to Drive
- **Download files** — Access documents stored in Drive from Frihet
- **Auto-organization** — Save documents in folders by client or year

## Requirements

- **Google account** — Gmail, Google Workspace, or Google One
- **Frihet Pro or higher**

:::info No credentials to enter
This integration uses OAuth with Google. You don't need to copy any API key or token. Simply authorize Frihet to access your Google Drive through a Google sign-in window.
:::

:::note Technical setup
This integration requires the `VITE_GOOGLE_CLIENT_ID` environment variable to be set on the Frihet server. If you're a Frihet Cloud user, this is already configured. If you self-host Frihet, see the [REST API documentation](../desarrolladores/api-rest.md).
:::

## Connect Google Drive to Frihet

### Step 1: Start the connection

1. Go to **Settings** → **Integrations**
2. Find **Google Drive**
3. Click **Connect with Google**

### Step 2: Authorize in Google

1. The Google sign-in window will open
2. Select your Google account
3. Review the permissions requested:
   - View, create, and delete files in Google Drive
   - View your account information
4. Click **Allow**

### Step 3: Verify connection

1. Back in Frihet, you'll see "Connected" with your Google account
2. Frihet will display your recent Drive files
3. The integration is ready to use

## How it works

Frihet uses the **Google Drive API** with an OAuth 2.0 redirect authorization flow:

1. You click "Connect with Google" and authorize in the Google window
2. Google generates access and refresh tokens
3. Frihet stores both tokens encrypted (AES-256-GCM)
4. With the access token, Frihet can list, search, upload, and download files
5. The token refreshes automatically when it expires
6. You never enter Google credentials directly in Frihet

## Synced data

| Data | Direction | Frequency |
|------|-----------|-----------|
| File listing | Google Drive → Frihet | On demand |
| File search | Google Drive → Frihet | On demand |
| Upload files | Frihet → Google Drive | On demand |
| Download files | Google Drive → Frihet | On demand |

## Features

### List files

1. From Frihet, go to the Google Drive section
2. You'll see your recent files and folders
3. Navigate through folders to find documents

Each file shows:
- Name
- Type (document, spreadsheet, PDF, image, etc.)
- Last modified date
- Size

### Search files

1. Use the Google Drive search bar in Frihet
2. Search by filename or content
3. Results include files across your entire Drive

### Upload files

Upload documents from Frihet directly to Google Drive:

1. Select the file to upload (invoice PDF, quote, document)
2. Choose the destination folder in Drive
3. The file uploads and becomes available in your Drive

### Download files

1. Navigate or search for the file in Drive from Frihet
2. Click **Download**
3. The file downloads to your device

## Use cases

### Automatic invoice backup

Every time you generate an invoice PDF, upload it to a Google Drive folder organized by year and month. Your accountant has access to the shared folder and can review invoices without needing to ask you for them.

### Centralized project documentation

Store contracts, proposals, and project documents in Google Drive. From Frihet, access those documents while working on project billing without switching applications.

### Share with your accountant

Create a "Frihet - Invoices 2026" folder in Drive and share it with your accountant. Upload invoices and documents from Frihet directly to that folder.

### Import documents for expenses

You have vendor invoices stored in Drive. From Frihet, download them to attach as receipts when logging expenses.

## Troubleshooting

### "Error connecting with Google"

- Verify your Google account is active
- If you use a corporate Google Workspace, your admin may have restricted third-party apps
- Check that you don't have popup blockers preventing the Google window from opening

### "I can't see my files"

- Verify you authorized access to Google Drive (not just Gmail)
- Files shared with you appear under "Shared with me"
- Refresh the view in Frihet

### "I can't upload files"

- Check that you have available storage in your Google Drive
- The file must not exceed Google Drive's size limit
- Verify your session hasn't expired

### "Session expired"

- Google may request re-authorization periodically
- Go to **Settings** → **Integrations** → **Google Drive** and click **Reconnect**
- You'll go through the Google authorization window again

### "I want to disconnect"

1. Go to **Settings** → **Integrations** → **Google Drive**
2. Click **Disconnect**
3. Tokens are deleted from Frihet
4. Optionally, revoke access at [myaccount.google.com/permissions](https://myaccount.google.com/permissions)

## Next steps

- [See the REST API for programmatic access](../desarrolladores/api-rest.md)
