/api/v4/connected-accounts/connect-google連結 Google 帳戶
傳回 OAuth URL,用於將 Google Business Profile 帳戶連結至您的 Listings API 帳戶。
參數
請求主體
| 名稱 | 類型 | 必填 | 說明 |
|---|---|---|---|
| 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.
產生短效的 OAuth URL,供使用者前往並授權 Listings API 批次管理其 Google Business Profile 地點。將使用者重新導向至傳回的 url;使用者完成 Google 同意畫面的流程後,會返回您提供的其中一個 URL。此連結的有效期限為 24 小時。
請求格式。 請求主體必須包在 input 物件中,且該物件必須包含 successUrl 和 errorUrl 這 2 個必填欄位。這些是使用者完成(或放棄)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" } }'