在Shopify公共应用中创建API并在Postman中调用它。

huangapple go评论68阅读模式
英文:

Create API In Shopify Public App And Call It In Postman

问题

I created shopify public app using yarn create @Shopify/app. I get nodejs code template will oAuth process and session token. Following is the API that i created in shopify public app.

我使用 "yarn create @Shopify/app" 创建了 Shopify 公共应用。我获取了Node.js代码模板,用于OAuth过程和会话令牌。以下是我在 Shopify 公共应用中创建的API。

在Shopify公共应用中创建API并在Postman中调用它。

现在,当我在 Postman 中调用此API时,我收到以下错误:

在Shopify公共应用中创建API并在Postman中调用它。

I am unable to find out that how to give shop name and where do I get shop name and access_token? And I wanted to ask that is it possible to call API which is created in shopify public app in other software? It would act as a third party integration. Kindly someone guide me.

我无法找出如何提供商店名称以及从哪里获取商店名称和访问令牌。我想问一下,是否可以在其他软件中调用在 Shopify 公共应用中创建的API?这将作为第三方集成。请有人指导我。

英文:

I created shopify public app using yarn create @Shopify/app. I get nodejs code template will oAuth process and session token. Following is the API that i created in shopify public app.

在Shopify公共应用中创建API并在Postman中调用它。

Now when I call this API in postman I get the following error

在Shopify公共应用中创建API并在Postman中调用它。

I am unable to find out that how to give shop name and where do I get shop name and access_token? And I wanted to ask that is it possible to call API which is created in shopify public app in other software? It would act as a third party integration. Kindly someone guide me.

答案1

得分: 1

抱歉,以下是翻译好的内容:

很不幸,Express Shopify 应用与您通常的 Express 应用不同。当客户安装您的应用时,他们被识别并存储为数据库中的“会话”。正如您所看到的错误消息:“未提供商店”。

“商店”和其他信息由前端提供。在底层,前端有代码来添加商店,以及一个安全的授权头部,一个“Bearer”令牌 useAuthenticatedFetch.js

因此,在前端代码中,它可能看起来很简单,ProductsCard.jsx:

const response = await fetch("/api/products/create");

不幸的是,Bearer 令牌依赖于时间戳,时间戳会过期,因此您需要快速生成令牌并将其复制粘贴到 Postman 中。

英文:

Unfortunately, the express Shopify App isn't like your usual Express apps. When a customer installs your app they are identified and stored as a "session" inside your database. As you can see the error that came back "No Shop Provided".

The "shop" and other information are provided by the fronted. Underneath the hood, the "frontend" there is code to add the shop and also a security Authorization header, a "Bearer" token useAuthenticatedFetch.js.

And so on the frontend code, it may look simple, ProductsCard.jsx:

const response = await fetch("/api/products/create");

Unfortunately, the bearer token keys off a timestamp, the time stamp does expire and so you'll need to quickly generate the token and copy-paste it into postman.

huangapple
  • 本文由 发表于 2023年6月27日 19:54:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/76564592.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定