Menambahkan Google Drive Channel
Yang Perlu Disiapkan Dahulu
Sebelum mulai, siapkan item berikut:
| Requirement | Mengapa Dibutuhkan |
|---|---|
| Google account | Digunakan untuk mengakses Google Cloud dan authorize Google Drive |
| Google Cloud project | Digunakan untuk enable Drive API dan membuat OAuth credentials |
| OAuth 2.0 client | Digunakan ImgBed untuk mendapatkan Client ID, Client Secret, dan Refresh Token |
| ImgBed domain Anda | Digunakan untuk OAuth redirect URI. Harus cocok dengan domain yang benar-benar Anda pakai. |
Langkah Setup
Step 1: Enable Google Drive API
- Buka Google Cloud Console.
- Buat project baru atau pilih project yang sudah ada.
- Masuk ke
APIs & Services. - Klik
Enable APIs and Services. - Cari
Google Drive API. - Buka dan klik enable.
Step 2: Configure OAuth Consent Screen
- Di Google Cloud, buka
Google Auth Platform. - Lengkapi informasi dasar
Branding, seperti app name, support email, dan developer contact email. - Buka
Audience. - Untuk kebanyakan self-hosted personal deployments, pilih
External. - Jika memilih
External, tambahkan Google account yang ingin diauthorize diTest users. - Buka
Data Access. - Tambahkan Google Drive permissions yang diperlukan.
Step 3: Buat OAuth 2.0 Client
- Di
Google Auth Platform, bukaClients. - Buat client baru.
- Set application type ke
Web application. - Beri nama client yang mudah dikenali.
- Untuk authorized JavaScript origins, masukkan ImgBed URL, misalnya:
text
https://img.example.com- Untuk authorized redirect URIs, masukkan:
text
https://img.example.com/api/oauth/google/callback

Setelah client dibuat, copy nilai ini:
| Generated Value | ImgBed Field |
|---|---|
| Client ID | Client ID |
| Client Secret | Client Secret |
Step 4: Isi Google Drive Channel
Di Upload Settings, pilih Google Drive dan isi:
| ImgBed Field | Yang Diisi |
|---|---|
| Channel name | Nama yang mudah dikenali, misalnya Main Google Drive |
| Client ID | Client ID dari Google Cloud |
| Client Secret | Client Secret dari Google Cloud |
| Refresh Token | Biarkan kosong dulu. Ambil di step berikutnya. |
| Root directory | Optional. Default adalah imgbed. |

Step 5: Dapatkan Refresh Token
- Klik
Get Token. - Pilih Google account yang ingin dihubungkan.
- Selesaikan authorization prompts.
- Callback page akan menampilkan
Refresh Token. - Copy token tersebut.
- Kembali ke ImgBed dan paste ke field
Refresh Token.

Jika nanti mengganti Google account, mengganti OAuth client, atau authorization lama expired, Anda tidak perlu menghapus channel. Buka edit page dan klik Reauthorize.
Step 6: Save Channel
Setelah semua field terisi, save channel.
Quick Flow
text
Buka Google Cloud
-> Buat atau pilih project
-> Enable Google Drive API
-> Configure Google Auth Platform
-> Jika Audience External, tambahkan Google account Anda ke Test users
-> Buat Web application OAuth client
-> Gunakan https://your-domain.com/api/oauth/google/callback sebagai redirect URI
-> Isi Client ID dan Client Secret ke ImgBed
-> Klik Get Token
-> Sign in dengan Google dan authorize
-> Copy Refresh Token dari callback page
-> Paste kembali ke ImgBed dan save
-> Upload test imageReferences
- Google OAuth Web Server Applications: https://developers.google.com/identity/protocols/oauth2/web-server
- Google Workspace OAuth Consent Configuration: https://developers.google.com/workspace/guides/configure-oauth-consent
- Google Drive API Auth Scopes: https://developers.google.com/workspace/drive/api/guides/api-specific-auth