Shopify Public App-如何获取钥匙,token& URL

发布于 2025-02-04 18:52:21 字数 301 浏览 3 评论 0原文

我是Shopify公共应用程序开发的新手,我将需要您的帮助才能更好地了解它。

对于客户,我需要构建一个将由几家商人使用的Shopify公共应用程序。

此应用程序将必须通过管理API访问商家商店。

如果我的理解是正确的,为了通过管理员API访问一个特定的商店,我需要从该商家商店中提供3片信息:公共API密钥,令牌和URL。

现在,我的问题: 当商家安装Shopify Public应用程序时,我的应用程序如何获取这三个信息(特定于该特定商家)? 有什么“魔术”技巧?商人需要输入此信息吗? ...

提前非常感谢您的帮助

I am totally new to Shopify Public App development and I will need your help to understand it a bit better.

For a client, I need to build a Shopify Public App that will be used by several Merchants.

This application will have to access the Merchants' store via the Admin API.

If my understanding is correct, in order to access one specific Merchant's store via the Admin API, I need to have 3 pieces of information from that Merchant's store: the Public API Key, Token and URL.

Now, my question:
When the Shopify Public App is installed by a Merchant, how does my app get these 3 pieces of information (specific to that particular merchant) ?
Is there any "magic" trick? Does the Merchant need to input this info? ...

In advance, many thanks for your help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

狠疯拽 2025-02-11 18:52:21

对于那些可能有兴趣的人,我终于找到了指向信息的链接。
shopify- oauth 开始

For those who might be interested, I finally found the link to the information.
Shopify - Getting started with OAuth

蹲在坟头点根烟 2025-02-11 18:52:21

每个商人都需要安装您的应用程序。在安装阶段中,Shopify将通过参数将访问令牌通过,即您需要的令牌,以便使用Admin API。

如果我们谈论的是一个嵌入式应用程序,则可以预见到每个请求都经过身份验证。

取决于您要创建的应用程序(或者嵌入式)和可能要使用的语言,使用Shopify CLI创建应用程序的初稿。它将创建一个可安装应用程序的基础。这是文档 https://shopify.dev/apps/getting-petting-started/create/create/create

您需要安装Shopify CLI,然后运行

Shopify App create(Node | Ruby | PHP)

根据您选择的语言。

Each merchant will need to install your app. In the installation phase shopify will pass, as an argument, the access token, that is a token that you will need, to use the Admin API.

If we're talking about an embedded app is expected that every request made is authenticated.

Depending on which kind of app you want to create (embedded or not) and language you may want to use, using the Shopify Cli to create the first draft of the app is really reccommended. It will create the base to have an installable app. Here is the documentation https://shopify.dev/apps/getting-started/create

You need to install the Shopify Cli and then run

shopify app create (node | ruby | php)

depending on your language of choice.

甜尕妞 2025-02-11 18:52:21

对于现在阅读本文的任何人,我最近都在同样的问题上挣扎。

Flow

这是一个简单的过程:

  • 创建Shopify Remix应用程序按照。这将是商店所有者在商店所有者安装应用程序
  • 时将在商店中安装的应用程序,从混音应用程序可以轻松访问 离线访问令牌
  • 如果您想在此混音应用程序中进行API调用,那么您就不需要做任何额外的事情“ rel =“ nofollow noreferrer”>模板本身。
  • 如果您想在后台运行某些任务,例如cron-job,则需要对节点(后端)应用程序进行身份验证。为此,您需要从Remix应用程序中访问令牌才能直接从您的后端获取有关商店的数据(在这种情况下为节点应用程序)。
  • 您可以将访问令牌发送到自定义后端并将其存储在DB中。
  • 由于默认创建的混音应用程序的令牌是离线访问令牌,它将保持有效,直到用户卸载该应用程序为止。

如何从Remix App(由官方模板制成)获取访问令牌

const { admin, session } = await authenticate.admin(request);
console.log(session);

此代码在官方文档
在这里,您可以安装session,并从中获得access_token

这对于任何新尝试的人来说可能会有些混乱。但我希望这会有所帮助!

For anyone reading this now, I recently struggled with the same problem.

Flow

Here is a simple process:

  • Create shopify remix app following the steps in the official docs. This will be the app that the store owner will install on their stores
  • When the store owner installs the app, from remix app you can easily access the offline access token.
  • If you want to do API calls within this remix app then you don't need to do anything extra because all auth is handled in the template itself.
  • If you want to run some tasks in the background like a cron-job then you need to authenticate your node (backend) app. For this you need the access token from remix app to get data about the shop directly from your backend (Node app in this case).
  • You can send the access token to your custom backend and store it in a db.
  • Since the token that remix app created by default is offline access token it will stay valid until the user uninstalls the app.

How to get the access token from remix app (made from official template)

const { admin, session } = await authenticate.admin(request);
console.log(session);

This code is provided in the official docs
Here you can console the session and get the access_token from it

This can be a little confusing for anyone new trying out. But I hope this helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文