简体   繁体   English

私人嵌入式shopify应用程序

[英]Private embedded shopify app

I'm trying to build Embedded Private App and something I'm missing. 我正在尝试构建嵌入式私有应用程序和我缺少的东西。 As it is instructed here , I created App, got API key. 正如这里所说,我创建了App,获得了API密钥。 Then a very simple page with content: 然后是一个非常简单的内容页面:

<head>
  <script src="https://cdn.shopify.com/s/assets/external/app.js"></script>
  <script type="text/javascript">
    ShopifyApp.init({
      apiKey: 'my-private-api-key',
      shopOrigin: 'https://my-dev-shop.myshopify.com',
      debug: true
    });
  </script>
</head>
<body>
Private app
</body>

And I'll I get by visiting this page is redirect to my shop with screen. 我将通过访问此页面重定向到我的商店与屏幕。

The page you're looking for can't be found.
Try a search instead.

Redirect URL is 重定向网址是

https://my-dev-shop.myshopify.com/admin/apps/my-private-api-key/ 

What I am missing? 我错过了什么? It's my first experience with shopify at all, so maybe I missing all understanding how EASDK works. 这是我第一次体验shopify,所以也许我错过了所有理解EASDK的工作方式。 I tested it from localhost and from my domain with SSL. 我使用SSL从localhost和我的域测试了它。 Thank you for any tips. 谢谢你的任何提示。

I would like to pay more attention to Embedded Apps and tell more about my experience and problems I met before I managed to create and install it as a private app. 我想更加关注嵌入式应用程序 ,并在我成功创建并安装为私有应用程序之前,先了解我遇到的经验和问题。

Embedded Apps allows to modify look and feel of admin part of Shopify. 嵌入式应用程序允许修改Shopify管理部分的外观。 Actually there is no special app type called "Embedded Apps" in Shopify. 实际上,Shopify中没有称为“嵌入式应用程序”的特殊应用程序类型。 App creator can just enable "Embedded App" SDK when he creates regular "public" app in his Partners account. 应用创建者只需在其合作伙伴帐户中创建常规“公共”应用时启用“嵌入式应用”SDK即可。 So if this feature is enabled - the app can use Embedded App SDK in store's admin. 因此,如果启用此功能,则应用可以在商店的管理员中使用Embedded App SDK。

My problem was to realize how to install Embedded App to the store and how to make it private ie available to stores without publishing to App Store. 我的问题是要实现如何将嵌入式应用程序安装到商店以及如何将其设置为私有,即可在不发布到App Store的情况下用于商店。 The answer is: 答案是:

  • we need create a regular public app with "Embedded App SDK" enabled (using partners account) 我们需要创建一个启用“Embedded App SDK”的常规公共应用程序(使用合作伙伴帐户)
  • we do not need to publish it to store (so no-one excepting us will know about it) 我们不需要将它发布到商店(所以除了我们之外没有人会知道它)
  • we need to install it in store's admin. 我们需要在商店的管理员中安装它。

Last action means that we need to do everything as it is described for regular public Shopify Apps ie allow the app to access the store using OAuth handshake. 最后一个操作意味着我们需要执行常规公共Shopify应用程序所描述的所有操作,即允许应用程序使用OAuth握手访问商店。 The procedure is described here . 这里描述该过程。

Let me repeat some points: 让我重复一些观点:

  1. Send request like this https://{shop}.myshopify.com/admin/oauth/authorize?client_id={api_key}&scope={scopes}&redirect_uri={redirect_uri}. 发送此请求https:// {shop} .myshopify.com / admin / oauth / authorize?client_id = {api_key}&scope = {scopes}&redirect_uri = {redirect_uri}。 Replace {strings in curly braces} with appropriate values. 用适当的值替换{花括号}中的{strings。 Note {redirect_uri} must be one of Redirection URL specified in app settings, {scopes} should be replaced with one of allowed scopes from here (I used the first scope, it was not important for me, I did not want to modify data, I just wanted t use Embedded App SDK UI methods). 注意{redirect_uri}必须是应用程序设置中指定的重定向URL之一,{scopes}应该替换为此处允许的范围之一(我使用了第一个范围,对我来说不重要,我不想修改数据,我只是想使用Embedded App SDK UI方法)。
  2. In result it will send you to example.org/some/redirect/uri?code={authorization_code}&hmac=da9d83c171400a41f8db91a950508985&timestamp=1409617544&state={nonce}&shop={hostname} (example.org/some/redirect/uri is a redirect_url pointed in first request) and expect that a this query is properly handled on your side. 结果它将发送给example.org/some/redirect/uri?code={authorization_code}&hmac=da9d83c171400a41f8db91a950508985&timestamp=1409617544&state={nonce}&shop={hostname}(example.org/some/redirect/uri是一个redirect_url指向在第一个请求中)并期望在您这边正确处理此查询。
  3. "Properly handled" means that POST request will be sent to https://{shop}.myshopify.com/admin/oauth/access_token and it will have following fields: “正确处理”意味着POST请求将发送到https:// {shop} .myshopify.com / admin / oauth / access_token,它将包含以下字段:
    • client_id - the API Key for the app client_id - 应用的API密钥
    • client_secret - the Shared Secret for the app client_secret - 应用程序的共享密钥
    • code - the {authorization_code} came with query. 代码 - {authorization_code}附带查询。

I did not need any backend stuff so I just created simple html form with all necessary fields and submitted it (method=POST, action=https://{shop}.myshopify.com/admin/oauth/access_token) and received a json with access token. 我不需要任何后端内容所以我只是创建了包含所有必填字段的简单html表单并提交了它(method = POST,action = https:// {shop} .myshopify.com / admin / oauth / access_token)并收到了json带访问令牌。

After it in admin of the store in Apps section you must see link to added app. 在应用程序部分的商店管理员中,您必须看到添加应用程序的链接。 After clicking on it here it will try to open load iframe with src equal to Application URL of your app. 点击此处后,它将尝试打开加载iframe,其中src等于应用程序的应用程序URL。 This URL must point to your app ie a html where you can do what you want. 此网址必须指向您的应用,即html,您可以在其中执行您想要的操作。 Normally people want to use SDK methods. 通常人们想要使用SDK方法。 Please note possible http/https issues 请注意可能的http / https问题

This error occurs if you set your "App settings" > "Embedded settings" to disabled (standalone app) but use your app as an embedded app. 如果您将“应用程序设置”>“嵌入式设置”设置为禁用(独立应用程序)但将您的应用程序用作嵌入式应用程序,则会出现此错误。 Just set your "Embedded settings" to enabled and your app will work fine. 只需将“嵌入式设置”设置为启用,您的应用就可以正常运行。

在此输入图像描述

I am stuck with the same problem and tried different things... 我遇到了同样的问题并尝试了不同的事情......

As stated on this forum post by a "Shopify Employee", it seems to be possible for a private app to be embedded. 正如“Shopify员工”在此论坛帖子中所述,似乎可以嵌入私人应用程序。 I can't find how though. 我怎么也找不到。

True private applications do not use OAuth and do not get listed in the Shopify admin, however you can create an App in your partners area, never publish it to the App store and only allow it to be installed on whichever shops you please. 真正的私有应用程序不使用OAuth,也不会在Shopify管理员中列出,但是您可以在合作伙伴区域创建应用程序,从不将其发布到App Store,只允许将其安装在您喜欢的任何商店。 These Apps will be listed in the admin and will have full access to the EASDK. 这些应用程序将列在管理员中,并具有对EASDK的完全访问权限。

This is what I did : 这就是我做的:

  • create a private app with EASDK enabled (Embedded Settings section on the app's settings page) 创建启用了EASDK的私有应用程序(应用程序设置页面上的“嵌入式设置”部分)
  • install my code on a HTTPS server 在HTTPS服务器上安装我的代码
  • create a private app key on my shop's settings page 在我店铺的设置页面上创建私人应用密钥

At this point, I could access my shop's products and orders through the PHP API, leading me to believe that my app was installed. 此时,我可以通过PHP API访问我的商店的产品和订单,让我相信我的应用程序已安装。

I then copied the code provided on Shopify's embedded app SDK initialization doc . 然后我复制了Shopify的嵌入式应用SDK初始化文档中提供的代码。 I open this page in my browser and am automatically redirected to a 404. URL oh that page looks like https://name-of-my-shop.myshopify.com/admin/apps/ID_OF_MY_APP/ 我在浏览器中打开此页面并自动重定向到404.该页面的URL看起来像https://name-of-my-shop.myshopify.com/admin/apps/ID_OF_MY_APP/

I also tried this (didn't work) : 我也试过这个(没用):

  • generate an "install link" using the PHP API's method install_url 使用PHP API的方法install_url生成“安装链接”
  • click on that link, showing the message (Name of my app) has been granted read/write access to your Shopify data. 单击该链接,显示消息(我的应用程序的名称)已被授予对Shopify数据的读/写访问权限。

Any input from a Shopify guru would be appreciated 任何Shopify大师的意见将不胜感激

NB. NB。 It also seems that the API evolves a lot and this might be a temporary issue, but I surely hope it is not and we can solve this ! 似乎API发展很多,这可能是一个临时问题,但我当然希望它不是,我们可以解决这个问题!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM