如何 get/generate 访问店面令牌 API

How to get/generate access token of storefront API

我正在使用 https://github.com/osiset/laravel-shopify 包来管理 Shopify API 和 laravel 8 并遇到以下错误:

HTTP/1.1 403 禁止访问 { "errors": "应用程序必须可扩展才能创建店面访问令牌。" }

正在尝试以下操作:

$shop = Auth::user();
$orders = $shop->api()->rest('POST', '/admin/api/2021-01/storefront_access_tokens.json', ['storefront_access_token' => ['title' => 'mobile']]);
dd($orders);

我想回答我自己的问题,因为最终我找到了解决方案: 要实现此目标,您必须满足以下要求:

  1. 一个 public shopify 应用程序
  2. 启用销售渠道(您可以在应用->您的应用->应用设置中找到它)
  3. Api 个具有以下值的范围:

read_products,write_products,unauthenticated_read_content,unauthenticated_read_customer_tags,unauthenticated_read_product_tags,unauthenticated_read_product_listings,unauthenticated_write_checkouts,unauthenticated_read_checkouts,unauthenticated_write_customers,unauthenticated_read_customers

然后您需要注销(如果已经登录),然后使用 shopify 重新进行身份验证,然后您就可以让它工作了。