【发布时间】:2020-08-05 20:21:39
【问题描述】:
我有一个由以下人员创建的 React 前端:https://shopify.dev/tutorials/build-a-shopify-app-with-node-and-react
这是一个NextJsReact 应用程序,带有一个自定义Koa 服务器来服务NextJs 应用程序。 Koa 服务器使用 koa-ashopify-auth 包通过 Shopify 执行 OAuth 并获取访问令牌。
这是授权中间件代码:
server.use(
createShopifyAuth({
apiKey: SHOPIFY_API_KEY as string,
secret: SHOPIFY_API_SECRET_KEY as string,
scopes: ['read_products'],
afterAuth(ctx) {
const { shop, accessToken } = ctx.session as IShopifyKoaSession
>>> I would like to create a user on my own backend now and login the user.
.... more stuff
}
})
)
我有一个Django 后端,我将设置一个 REST 端点来对我的后端进行身份验证(我想使用 JWT)。
所以我在客户端使用 Shopify 执行了 OAuth 并拥有访问令牌
如何使用此客户端访问令牌并以安全的方式在我的后端创建新用户?
我在想类似 ->
...
const { shop, accessToken } = ctx.session as IShopifyKoaSession
await myApiService.createOrUpdateUser(shop, accessToken) // Calls my external backend
我该怎么做呢?这基本上是一个隐式的 oauth 流程。
除非有办法在后端验证商店和访问令牌,否则上述内容将不安全。
【问题讨论】:
标签: django oauth shopify next.js