DocScan

Đang mở camera…
Chất lượng
0%

Tài liệu

Trang

Xuất & chia sẻ

Cài đặt

Chụp

Xử lý & xuất
Google Drive

Giao diện

Kim – Thổ: vàng kim, trắng ngà, nâu đất; tránh đỏ, cam, hồng, tím.

Hẹn giờ chụp hàng loạt

Đặt máy cố định (giá đỡ), lật trang theo nhịp – app tự chụp sau mỗi khoảng thời gian, không giới hạn số trang.

Cấu hình Google Drive

Làm một lần, khoảng 10 phút, miễn phí. Bạn tự tạo "chìa khoá" (Client ID) để app được phép lưu file vào Drive của bạn. Không cần server, không có khoá bí mật nào nằm trong app.

  1. Tạo project trên Google Cloud

    Đăng nhập bằng Gmail sẽ dùng để lưu file → tạo project mới, đặt tên tuỳ ý (VD DocScan) → Create. Các bước sau nhớ chọn đúng project này ở thanh trên cùng.

    Mở trang tạo project ↗
  2. Bật Google Drive API

    Mở trang Google Drive API → bấm Enable (nếu thấy Manage là đã bật rồi).

    Mở Google Drive API ↗
  3. Khai báo màn hình xin quyền (Google Auth Platform)

    Branding: điền App name (VD DocScan), User support email, Developer contact → Save.
    Audience: chọn External. Rồi chọn một trong hai:

    • Publish app → In production (khuyên dùng): vì app chỉ xin quyền drive.file (loại không nhạy cảm) nên không cần Google xét duyệt, không bị hết hạn sau 7 ngày.
    • Giữ Testing: thêm Gmail của bạn (và người dùng khác) vào Test users. Chế độ này tối đa 100 người và quyền đã cấp hết hạn sau 7 ngày.

    Data Access → Add or remove scopes → tìm và tích .../auth/drive.file → Update → Save.

    Branding ↗ Audience ↗ Data Access ↗
  4. Tạo Client ID

    Clients → Create client → Application type: Web application → đặt tên.
    Mục Authorized JavaScript origins → Add URI → dán đúng địa chỉ app này:

    Chỉ ghi giao thức + tên miền (+ cổng), không có dấu “/” hay đường dẫn ở cuối. Mỗi địa chỉ bạn dùng app (VD bản thật trên Netlify và bản thử http://localhost:3000) phải thêm riêng. Mục Authorized redirect URIs để trống. Bấm Create.

    Mở trang Clients ↗
  5. Dán Client ID vào app

    Sao chép Client ID có dạng 123456789012-abc…xyz.apps.googleusercontent.com (không phải Client secret) → dán vào ô Google OAuth Client ID trong Cài đặt → bấm Kết nối Google Drive → chọn tài khoản → Cho phép.

  6. Kiểm tra

    Bấm Kiểm tra trong Cài đặt. Nếu thấy “✓ Drive hoạt động” là xong: nút Lưu Drive sẽ lưu vào thư mục DocScan/<tên tài liệu>.

    Địa chỉ vừa thêm ở Bước 4 có thể cần 5 phút đến vài giờ mới có hiệu lực – nếu báo origin_mismatch ngay sau khi tạo, hãy chờ rồi thử lại.

Gặp lỗi? Bảng tra nhanh
Thông báoCách sửa
Error 400: origin_mismatchĐịa chỉ ở Bước 4 sai (thừa “/”, sai http/https, thiếu cổng, khác tên miền) hoặc chưa kịp có hiệu lực.
Error 403: access_denied / “app chưa được Google xác minh”App đang ở Testing mà Gmail chưa có trong Test users → thêm vào, hoặc Publish app.
Error 401: invalid_clientDán nhầm Client secret hoặc Client ID bị thiếu ký tự / đã bị xoá.
“Google Drive API has not been used…”Chưa làm Bước 2 hoặc bật ở project khác. Bật xong chờ 1–2 phút.
Bấm Kết nối không thấy gìTrình duyệt chặn cửa sổ bật lên → cho phép pop-up cho trang này.
“Cần HTTPS”Đưa app lên Netlify/Vercel/GitHub Pages, hoặc chạy npx serve . và mở qua http://localhost. Mở trực tiếp file index.html không dùng được Drive.

Quyền riêng tư: với drive.file, app chỉ thấy và sửa các file do chính nó tạo, không đọc được file khác trong Drive. Có thể thu hồi quyền bất cứ lúc nào tại myaccount.google.com/connections.

Google Drive setup

Do this once, about 10 minutes, free. You create your own "key" (Client ID) that lets the app save files to your Drive. No server, and no secret key is stored in the app.

  1. Create a Google Cloud project

    Sign in with the Gmail account you want to save files to → create a new project with any name (e.g. DocScan) → Create. In the next steps, make sure this project is selected in the top bar.

    Open project creation ↗
  2. Enable the Google Drive API

    Open the Google Drive API page → click Enable (if you see Manage, it is already enabled).

    Open Google Drive API ↗
  3. Set up the consent screen (Google Auth Platform)

    Branding: fill in App name (e.g. DocScan), User support email, Developer contact → Save.
    Audience: choose External. Then choose one of:

    • Publish app → In production (recommended): the app only requests drive.file (a non-sensitive scope), so no Google review is needed and access does not expire after 7 days.
    • Keep Testing: add your Gmail (and other users) under Test users. Limited to 100 users, and granted access expires after 7 days.

    Data Access → Add or remove scopes → find and tick .../auth/drive.file → Update → Save.

    Branding ↗ Audience ↗ Data Access ↗
  4. Create a Client ID

    Clients → Create client → Application type: Web application → give it a name.
    Under Authorized JavaScript origins → Add URI → paste this app's exact address:

    Only scheme + domain (+ port) – no trailing “/” or path. Add every address you use the app from (e.g. your Netlify site and http://localhost:3000 for testing). Leave Authorized redirect URIs empty. Click Create.

    Open Clients ↗
  5. Paste the Client ID into the app

    Copy the Client ID, which looks like 123456789012-abc…xyz.apps.googleusercontent.com (not the Client secret) → paste it into Google OAuth Client ID in Settings → tap Connect Google Drive → choose your account → Allow.

  6. Test

    Tap Test in Settings. If you see “✓ Drive works”, you are done: Save to Drive will save into DocScan/<document name>.

    The address added in Step 4 may take 5 minutes to a few hours to take effect – if you get origin_mismatch right after creating it, wait and try again.

Errors? Quick reference
MessageFix
Error 400: origin_mismatchThe address in Step 4 is wrong (trailing “/”, http vs https, missing port, different domain) or has not taken effect yet.
Error 403: access_denied / “Google hasn’t verified this app”The app is in Testing and your Gmail is not in Test users → add it, or publish the app.
Error 401: invalid_clientThe Client secret was pasted, the Client ID is incomplete, or the client was deleted.
“Google Drive API has not been used…”Step 2 was skipped or done in another project. Wait 1–2 minutes after enabling.
Nothing happens on ConnectThe browser blocked the pop-up → allow pop-ups for this site.
“HTTPS required”Deploy to Netlify/Vercel/GitHub Pages, or run npx serve . and open http://localhost. Opening index.html directly cannot use Drive.

Privacy: with drive.file, the app can only see and edit files it created itself – not the rest of your Drive. Revoke access any time at myaccount.google.com/connections.