首先,当我点击我的应用程序时,我的应用程序会在一个新的浏览器窗口中打开,而不是在 shopify 面板中。我想在用户安装 shopify 应用程序后使用他们的 storeUrl 登录用户或单击 shopify“myapps”部分中的应用程序。我该怎么做?目前这是我的 shopify 身份验证代码。
server.use(
createShopifyAuth({
apiKey: SHOPIFY_API_KEY,
secret: SHOPIFY_API_SECRET,
scopes: ['read_products', 'write_products'],
async afterAuth(ctx: any) {
const { shop, accessToken } = ctx.session;
ctx.cookies.set("shopOrigin", shop, {
httpOnly: false,
secure: true,
sameSite: 'none'
});
const registration = await registerWebhook({
address: `${HOST}/api/app/uninstalled`,
topic: 'APP_UNINSTALLED',
accessToken,
shop,
apiVersion: ApiVersion.July20
});
if (registration.success) {
console.log('Successfully registered webhook!');
} else {
console.log('Failed to register webhook', registration.result);
}
await CallbackShopifyUsecase.execute(shop, accessToken, ctx);
return ctx.redirect("/");
}
})
);