API Spreadsheet & Drive - Google Cloud Console dengan Service Account

Petunjuk Membuat Service Account untuk Google API

Mengakses Spreadsheet dengan Service Account

Untuk mengakses Google Sheets menggunakan Service Account, buat terlebih dahulu Service Account dan siapkan kunci dalam format JSON, lalu simpan sebagai credentials.json.

Alur Lengkap Pembuatan Service Account dan JSON Key

  1. Masuk ke Google Cloud Console lalu klik Select Project.
  2. Create Service Accounts.
  3. Aktifkan IAM API.
  4. Enable access to API.
  5. Nama proyek:
    • Contoh: My Project 90684, dengan Project ID: fabled-era-466003-m6.
    • Nama proyek bisa diubah di Settings (klik ikon pensil/edit lalu save).
    • Project ID tidak bisa diubah.
  6. Klik Continue dan ikuti tautan seperti: Now that you are done, go to https://console.cloud.google.com.
  7. Buka APIs & Services untuk mengelola API dan OAuth credentials.
  8. Di halaman Service Accounts, isi data berikut:
    1. Service account name: Gunakan nama sesuai fungsinya, huruf kecil dan tanda -. Contoh: sheets-editor, sheets-access.
    2. Service account ID: Biasanya diisi otomatis, bisa diganti.
    3. Description: Jelaskan tujuan akun, contoh:
      • Used by Python script to access Google Sheets
      • For automating Sheets and Drive API
      • Access Sheets as Editor
      • Used by Python app to access Sheets
    4. Principals with access (optional):
      Kosongkan jika hanya ingin memakai credentials.json di Python/Apps Script dan tidak memberi akses deploy Cloud/VM ke user lain.
    5. Service account users role:
      Centang hanya jika ada user lain yang perlu deploy Cloud Run/VM menggunakan Service Account ini. Jika hanya digunakan di Python → tidak perlu dicentang.
    6. Service account admins role:
      Kosongkan jika hanya Anda yang akan mengatur akun ini. Jangan beri akses ke orang lain jika tidak perlu.
  9. Klik ikon titik tiga () → pilih Manage keys.
  10. Klik Create new key → pilih JSON (bukan P12).
  11. Aktifkan API yang diperlukan:
    • Buka menu Library.
    • Cari Google Sheets API → klik Enable.
    • Cari juga Google Drive API → klik Enable.

Di bagian notifikasi aktif di kanan atas, terdapat aktivitas yang ditampilkan mulai dari yang terawal di bawah, seperti My Project, iam.googleapis.com, dan project berikutnya. Setelah langkah tersebut, file credentials.json akan terunduh otomatis dan siap digunakan pada aplikasi Python, Apps Script, atau aplikasi lainnya untuk mengakses API seperti Google Sheets dan Drive.

Comments

Popular posts from this blog

Analisis Potensi Rebound Saham (compose view): Kode Python & colab.research.google.com

Proyek Scraping Python

Adaptasi Integrasi Fitur Vault HTML CSS JS ke Python