为Shopify用户搭建第三方工具,如何访问数据?

Building a third-party tool for Shopify users, how to access data?

今天我有一个有趣的用例。

我和我的团队正在构建一个免费的第三方计算器工具,使用户能够使用他们商店的数据计算指标。

我们正在寻找获取必要数据并执行计算以向用户展示的方法...到目前为止,我们想出的最好方法是要求用户从 Shopify 导出报告并将其上传到我们的应用程序。

寻找与此类似的用户体验:

  1. 用户打开我们的工具,应用程序托管在 custom-domain.com

  2. 用户以某种方式验证或登录 Shopify,或批准我们的应用临时访问他们的数据。

  3. 我们的应用程序为用户执行计算,结束数据访问

关于如何促进这种身份验证或数据访问有什么想法吗? Shopify 似乎没有 'login with Google' 类型的身份验证按钮。

谢谢!

认证访问有两种模式,即在线和离线。在这种情况下,您需要的是在线访问。

来自Shopify Docs

Tokens with online access mode are linked to an individual user on a store, where the access token's lifespan matches the lifespan of the user's web session. This type of access mode is meant to be used when a user is interacting with your app through the web, or when an app must respect an individual user's permission level.This access mode must be explicitly requested in the authorization phase.

它还应该满足您与终止数据访问相关的需求。

  • An access token created with this access mode is temporary, and is guaranteed to expire after some amount of time.
  • When a user logs out of Shopify admin, all online mode access tokens created during the same web session are revoked.

获得访问令牌后,您可以使用 Shopify API 查询数据,这样您的用户就不必手动上传任何文件。