/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,用户访问该 URL 后,可授权 Listings API 批量管理其 Google Business Profile 地点。将用户重定向至返回的 url;用户在 Google 授权同意页面完成操作后,会被重定向至您提供的其中一个 URL。该链接的有效期为 24 小时。
请求结构。 请求体必须封装在一个 input 对象中,该对象包含 2 个必填字段:successUrl 和 errorUrl。这些字段的值是绝对 https URL,用户完成(或放弃)Google 授权同意页面后会被重定向至这些 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" } }'