📄 SKILL.md

← Vault

name: doccorretor-google-drive-migration

description: Migrate documents from Google Drive to DocCorretor — OAuth setup, rclone config, and migration strategies

tags:

- google-drive

- doccorretor

- migration

- oauth


DocCorretor Google Drive Migration

Context

DocCorretor (documentos.rochasalesseguros.com.br) needs to migrate documents from Google Drive. The Drive folder contains documents organized by month and client name (uppercase). The DocCorretor app uses the same Google OAuth app (GOOGLE_CLIENT_ID_REDACTED) already configured in its .env.

Google OAuth Setup (One-Time)

Step 1: Get authorization code

User opens this URL (while logged into the Drive account):

`

https://accounts.google.com/o/oauth2/v2/auth?client_id=GOOGLE_CLIENT_ID_REDACTED&response_type=code&scope=https://www.googleapis.com/auth/drive.readonly&redirect_uri=http://localhost:1/callback&access_type=offline&prompt=consent

`

After accepting, the page will show "redirect_uri não encontrado" — copy the code= parameter from the URL.

Step 2: Exchange code for tokens

`bash

curl -s -X POST https://oauth2.googleapis.com/token \

-H "Content-Type: application/x-www-form-urlencoded" \

-d "client_id=GOOGLE_CLIENT_ID_REDACTED" \

-d "client_secret=GOOGLE_CLIENT_SECRET_REDACTED" \

-d "code=USER_CODE_HERE" \

-d "redirect_uri=http://localhost:1/callback" \

-d "grant_type=authorization_code"

`

Returns: access_token, refresh_token, expires_in

Step 3: Save token and use with rclone or Drive API

`python

import json

token = {"access_token": "REDACTED", "refresh_token": "...", "expiry": ...}

with open('/tmp/gdrive_token.json', 'w') as f:

json.dump(token, f)

`

rclone Configuration (Post-Auth)

`ini

[gdrive]

type = drive

scope = drive.readonly

token = {"access_token":"...","refresh_token":"...","token_type":"Bearer","expiry":"..."}

`

Then list with:

`bash

rclone lsjson --config /tmp/rclone-gdrive.conf --drive-root-folder-id FOLDER_ID --recurse gdrive:/

`

Key Files

Migration Options

1. Automatic: Script parses filenames, matches to existing clients, creates folder structure

2. Review mode: List all files first, present plan for user approval before importing

3. Manual selective: User picks which folders/files to import one by one