/api/v4/connected-accounts/connect-googleGoogle アカウントを接続する
Google Business Profile アカウントを Listings API アカウントにリンクするための OAuth URL を返します。
パラメーター
ボディ
| 名前 | 型 | 必須 | 説明 |
|---|---|---|---|
| input | object | 必須 | Wrapper object. The entire request body must be nested under `input`. |
| input.successUrl | string | 必須 | URL the user is redirected to after they successfully authorize Google. Must be an absolute https URL you control. |
| input.errorUrl | string | 必須 | URL the user is redirected to if they cancel or the authorization fails. Must be an absolute https URL you control. |
リクエストの例
そのまま貼り付けられるボディです。プレースホルダーの ID と値をご自身のものに置き換えてください。
{ "input": { "successUrl": "https://listingsapi.com/docs/api/connected-accounts-trigger-matches", "errorUrl": "https://listingsapi.com/docs/api/connected-accounts-connect" }}レスポンス
200OAuth URL generated successfully. Redirect the user to `url` to begin the Google authorization flow. The `url` shown is a placeholder; send the user to the `url` returned in your own response.
{ "data": { "bulkConnectLinkForGoogle": { "errors": null, "success": true, "url": "https://connect.example.com/oauth?token=8f3c1d92-..." } }}400Bad request, the body was not wrapped in `input`, or `successUrl`/`errorUrl` was omitted (error message: `Variable "$input" of required type "GoogleOauthBulkInput!" was not provided`).
401Unauthenticated, missing or invalid API key.
ユーザーがアクセスして、Listings API に Google Business Profile の拠点を一括管理する権限を付与するための、有効期間の短い OAuth URL を生成します。返された url にユーザーをリダイレクトすると、ユーザーは Google の同意画面で操作を完了した後、指定した URL のいずれかに戻ります。リンクの有効期間は 24 時間です。
リクエストの構造。 リクエストボディは、2 つの必須フィールド successUrl と errorUrl を含む input オブジェクトでラップする必要があります。これらは、ユーザーが Google の同意画面で操作を完了した後(または中断した後)に戻る先の絶対 https URL です。成功時にはオンボーディングを再開し、エラー時には再試行できるようにする、ご自身のアプリケーションのエンドポイントを指定してください。accountId フィールドは存在せず、接続リンクのスコープは常に API キーを所有するアカウントに限定され、accountId(またはラップされていないフラットなリクエストボディ)を送信すると HTTP 400 で拒否されます。
これは一括接続ワークフローの最初の手順です。アカウントの認可が完了すると、接続済みアカウントの一覧を取得するエンドポイント(GET /connected-accounts)に、その後のすべての呼び出しで使用する connectedAccountId とともに表示されます。
ユースケース:代理店のクライアントの Google プロフィールをオンボーディングする。 新しいクライアントが Google Business Profile へのアクセス権を引き渡します。このエンドポイントを呼び出し、返された url にクライアントをリダイレクトすると、クライアントの同意後に、その Google 掲載情報が新しい接続済みアカウントで利用できるようになります。次に、POST /connected-accounts/trigger-matches を実行してそれらの Google 掲載情報を Listings API の拠点と照合し、GET /connected-accounts/{connectedAccountId}/connection-suggestions で対応付けを確認して、POST /connected-accounts/confirm-matches で確定します。
ユースケース:有効期限が切れた認証情報を修復する。 接続済みアカウントの Google トークンの有効期限が切れると、掲載情報の更新が同期されなくなります。このエンドポイントで接続リンクを再発行し、アカウント所有者に再度認可してもらうと、接続が重複して作成されることなく、既存の接続が更新されます。
Facebook の場合は、connect-facebook エンドポイントを使用してください。success: true で url が null でない場合は、リンクが生成されたことを意味します。errors に値が設定されるのは、生成に失敗した場合のみです。
curl -X POST 'https://listingsapi.com/api/v4/connected-accounts/connect-google' \ -H "Authorization: API $LISTINGSAPI_KEY" \ -H 'Content-Type: application/json' \ -d '{ "input": { "successUrl": "https://listingsapi.com/docs/api/connected-accounts-trigger-matches", "errorUrl": "https://listingsapi.com/docs/api/connected-accounts-connect" } }'