{
"client_id":"",
"client_secret":"",
"code":""
}
https://test-app.myshopify.com/admin/oauth/access_token
当我点击此端点的 api 来获取脱机访问令牌时,显示类似“未找到授权代码或已使用授权代码”的错误。
app.get("/auth/callback", async (req, res) => {
try {
console.log("redirectUrl", req);
const session = await Shopify.Auth.validateAuthCallback(
req,
res,
req.query
);
const host = req.query.host;
const code = req.query.code
app.set(
"active-shopify-shops",
Object.assign(app.get("active-shopify-shops"), {
[session.shop]: session.scope,
})
);
const response = await Shopify.Webhooks.Registry.register({
shop: session.shop,
accessToken: session.accessToken,
topic: "APP_UNINSTALLED",
path: "/webhooks",
});
if (!response["APP_UNINSTALLED"].success) {
console.log(
`Failed to register APP_UNINSTALLED webhook: ${response.result}`
);
}
// Redirect to app with shop parameter upon auth
res.redirect(`/?shop=${session.shop}&host=${host}&code=${code}`);
} catch (e) {
}
}
});
从重定向 URL 获取代码并发送到 iframe 并从下一个 web 应用程序发布 api 我无法找到代码在我这边使用的位置,或者这是后端问题。目前我正在使用应用程序中的访问令牌连接到shopify。是可用于刷新令牌的任何刷新令牌。我们需要一个永不过期的离线令牌。