Skip to content

Een Google Drive-kanaal toevoegen

Wat je vooraf nodig hebt

Bereid deze zaken voor:

VereisteWaarom je dit nodig hebt
Google-accountVoor toegang tot Google Cloud en autorisatie van Google Drive
Google Cloud-projectVoor het inschakelen van de Drive API en het maken van OAuth-gegevens
OAuth 2.0-clientHiermee kan ImgHost Client ID, Client Secret en Refresh Token ophalen
Je ImgHost-domeinVoor de OAuth-redirect-URI. Dit moet overeenkomen met het domein dat je echt gebruikt.

Instellen

Stap 1: Schakel de Google Drive API in

  1. Open Google Cloud Console.
  2. Maak een nieuw project of selecteer een bestaand project.
  3. Ga naar APIs & Services.
  4. Klik op Enable APIs and Services.
  5. Zoek naar Google Drive API.
  6. Open deze en klik op inschakelen.

Stap 2: Configureer het OAuth-toestemmingsscherm

  1. Open in Google Cloud Google Auth Platform.
  2. Vul de basisinformatie in bij Branding, zoals appnaam, supportmail en ontwikkelaarcontact.
  3. Open Audience.
  4. Voor de meeste persoonlijke self-hosted installaties kies je External.
  5. Kies je External, voeg dan bij Test users het Google-account toe dat je wilt autoriseren.
  6. Open Data Access.
  7. Voeg de benodigde Google Drive-rechten toe.

Stap 3: Maak een OAuth 2.0-client

  1. Open in Google Auth Platform de sectie Clients.
  2. Maak een nieuwe client.
  3. Zet het toepassingstype op Web application.
  4. Geef de client een herkenbare naam.
  5. Vul bij authorized JavaScript origins je ImgHost-URL in, bijvoorbeeld:
text
https://img.example.com
  1. Vul bij authorized redirect URIs in:
text
https://img.example.com/api/oauth/google/callback

OAuth-client maken

Domein en callback-URL invullen

Kopieer na het aanmaken deze waarden:

Gegenereerde waardeImgHost-veld
Client IDClient ID
Client SecretClient Secret

Stap 4: Vul het Google Drive-kanaal in

Kies in Uploadinstellingen Google Drive en vul in:

ImgHost-veldWat je invult
KanaalnaamEen herkenbare naam, bijvoorbeeld Main Google Drive
Client IDDe Client ID uit Google Cloud
Client SecretHet Client Secret uit Google Cloud
Refresh TokenLaat voorlopig leeg. Dit haal je in de volgende stap op.
HoofdmapOptioneel. Standaard imgbed.

Clientgegevens in ImgHost invullen

Stap 5: Haal het Refresh Token op

  1. Klik op Get Token.
  2. Kies het Google-account dat je wilt koppelen.
  3. Rond de autorisatiestappen af.
  4. De callbackpagina toont een Refresh Token.
  5. Kopieer het.
  6. Ga terug naar ImgHost en plak het in Refresh Token.

Refresh Token na autorisatie kopiëren

Als je later van Google-account wisselt, de OAuth-client verandert of de oude autorisatie verloopt, hoef je het kanaal niet te verwijderen. Open de bewerkpagina en klik op Reauthorize.

Stap 6: Sla het kanaal op

Sla het kanaal op zodra alle velden zijn ingevuld.

Snelle flow

text
Open Google Cloud
-> Create or select a project
-> Enable Google Drive API
-> Configure Google Auth Platform
-> If Audience is External, add your Google account to Test users
-> Create a Web application OAuth client
-> Use https://your-domain.com/api/oauth/google/callback as the redirect URI
-> Fill Client ID and Client Secret into ImgHost
-> Click Get Token
-> Sign in with Google and authorize
-> Copy the Refresh Token from the callback page
-> Paste it back into ImgHost and save
-> Upload a test image

Referenties

  1. Google OAuth Web Server Applications: https://developers.google.com/identity/protocols/oauth2/web-server
  2. Google Workspace OAuth Consent Configuration: https://developers.google.com/workspace/guides/configure-oauth-consent
  3. Google Drive API Auth Scopes: https://developers.google.com/workspace/drive/api/guides/api-specific-auth

Released as user documentation for ImgHost.