ドキュメントを閲覧

OpenConnector 用の Google OAuth app を作成する

self-hosted OOMOL OpenConnector runtime から user の Google account を接続する場合は、Google OAuth app を使用します。1 つの Google Cloud project に、Gmail、Google Drive、Google Calendar、Google Sheets、Google Docs、Google Slides、YouTube、Google Analytics、Google BigQuery、その他の Google API providers で使用する OAuth client を設定できます。

OpenConnector サービス

一般的な Google OAuth service IDs は次のとおりです。

サービス IDプロバイダー
gmailGmail
googledriveGoogle Drive
googlecalendarGoogle Calendar
googlesheetsGoogle Sheets
googledocsGoogle Docs
googleslidesGoogle Slides
youtubeYouTube
google_analyticsGoogle Analytics
google_bigqueryGoogle BigQuery

各 service は、OpenConnector に独自の OAuth client config を保存します。同じ redirect URI と必要な APIs、scopes を client が許可している場合は、複数の Google services で同じ Google OAuth client ID と client secret を再利用できます。

前提条件

  • 実行中の OpenConnector runtime。
  • Google Cloud project にアクセスできる Google account。
  • Google Cloud で OAuth consent の設定、APIs の有効化、OAuth credentials の作成を行う permission。
  • users が browser で開く OpenConnector origin(http://localhost:3000https://connect.example.com など)。

手順 1:OpenConnector callback URL を設定する

local test では次の URL を使用します。

http://localhost:3000/oauth/callback

public runtime では、最初に OOMOL_CONNECT_ORIGIN を設定し、次の URL を使用します。

https://connect.example.com/oauth/callback

手順 2:Google Cloud project を準備する

Google Cloud Console で次の操作を行います。

  1. project を作成または選択します。
  2. APIs & Services を開きます。
  3. OpenConnector service に必要な APIs(Gmail API、Google Drive API、Google Calendar API、Google Sheets API、YouTube Data API、Google Analytics Data API、BigQuery API など)を有効にします。
  4. OAuth consent screen を開き、Google から要求された app name、support email、audience、contact information、test users を設定します。
  5. OpenConnector service に必要な scopes を追加するか、OAuth request の開始時に consent screen へ表示します。

sensitive または restricted scopes を production で広く使用するには、Google の verification が必要になる場合があります。local use または internal testing では、Google account type で許可される testing または internal state に app を保持してください。

手順 3:OAuth credentials を作成する

APIs & Services > Credentials で次の操作を行います。

  1. Create credentials を選択します。
  2. OAuth client ID を選択します。
  3. Web application を選択します。
  4. authorized redirect URIs に OpenConnector callback URL を正確に追加します。
  5. client を作成します。
  6. client ID と client secret をコピーします。

Google の公式 OAuth ガイドは Using OAuth 2.0 for Web Server Applications です。

手順 4:client を OpenConnector に保存する

接続する service の OpenConnector web console を使用します。

  1. http://localhost:3000 などの OpenConnector web console を開きます。
  2. Providers を開き、Gmail または別の Google provider を選択します。
  3. Configure OAuth Client または Edit OAuth Client を選択します。
  4. Google client ID と client secret を貼り付けます。
  5. Save OAuth Client を選択します。

同じ Google OAuth client を別の Google provider でも使用する場合は、各 Google provider page でこの手順を繰り返します。

手順 5:接続してテストする

OAuth client を保存した後、Google provider page で Connect を選択します。Google consent を完了し、OpenConnector に戻って、provider page に account が connected と表示されることを確認します。

Gmail の low-risk test actions には、gmail.get_profilegmail.list_labels があります。action を実行する前に、console の action details で正確な input を確認してください。

トラブルシューティング

症状確認事項
redirect_uri_mismatchGoogle に送信される URI が OAuth client の authorized redirect URI と完全に一致している必要があります。<openconnector-origin>/oauth/callback であることを確認します。
Google が app を unverified と表示する許可された test users でテストを続けるか、利用可能な場合は internal mode を使用するか、広範に利用する前に Google verification を完了します。
Google が refresh token を発行しないaccount を再接続します。OpenConnector Google providers は、provider definition で refresh tokens が必要な場合に offline access と consent を要求します。
Google action が insufficient permissions を返すGoogle Cloud で必要な API を有効にし、必要な scope を追加または承認してから account を再接続します。
誤った Google account が使用される対象の Google account にサインインした browser profile から再接続します。

Google client secrets は secret manager に保管し、OpenConnector に OAuth clients を保存する前に OOMOL_CONNECT_ENCRYPTION_KEY を設定してください。