I have created my non-embedded public Shopify app. Now everything works on development store. Now when i am ready to submit it for app review, it fails on “Automated checks for common errors“.
My Authentication and Redirections Code is like this:
app.get(“/”, async (req, res) => {
try {
**const shop = validateShop(req.query.shop);**
**const { appKey, appSecret } = getAppCredentials(shop);**
**const shopify = shopifyApi({**
**apiKey: appKey,**
**apiSecretKey: appSecret,**
**scopes: \["read_products", "write_products", "read_themes", "write_themes", "read_script_tags", "write_script_tags", "read_orders", "write_orders", "read_customers", "unauthenticated_read_product_listings", "unauthenticated_write_checkouts"\],**
**hostName: process.env.SHOPIFY_APP_URL.replace(/^https?:\\/\\//, ''),**
**apiVersion: LATEST_API_VERSION,**
**isEmbeddedApp: false**
**});**
**if (!shop) {**
**return res.status(400).send("Missing Shop parameter");**
**};**
const authRoute = await shopify.auth.begin({
**shop,**
**callbackPath: "/auth/callback",**
**isOnline: false,**
**rawRequest: req,**
**rawResponse: res,**
**});**
return res.redirect(authRoute);
} catch (error) {
**return res.status(400).send(\`Authentication error: ${error.message}\`);**
}
**});
app.get(“/auth/callback”, async (req, res) => {**
try {
**const storeName = validateShop(req.query.shop);**
**const { appKey, appSecret } = getAppCredentials(storeName);**
**const isValid = verifyHMAC(req.query, appSecret);**
**if (!isValid) {**
**logger.error("Invalid HMAC");**
**return res.status(400).send("Invalid HMAC");**
**}**
**const shopify = shopifyApi({**
**apiKey: appKey,**
**apiSecretKey: appSecret,**
**scopes: \["read_products", "write_products", "read_themes", "write_themes", "read_script_tags", "write_script_tags", "read_orders", "write_orders", "read_customers", "unauthenticated_read_product_listings", "unauthenticated_write_checkouts"\],**
**hostName: process.env.SHOPIFY_APP_URL.replace(/^https?:\\/\\//, ''),**
**apiVersion: LATEST_API_VERSION,**
**isEmbeddedApp: false**
**});**
**
**
**const session = await shopify.auth.callback({**
**rawRequest: req,**
**rawResponse: res,**
**});**
**const { shop, accessToken } = session.session;**
**if (!shop || !accessToken) {**
**throw new Error("Missing shop or access token");**
**}**
**/\*\* now lets fetch the store info \*/**
**const storeInfoURL = \`https://${shop}/admin/api/${LATEST_API_VERSION}/shop.json\`;**
**const storeInfoRes = await fetch(storeInfoURL, {**
**method: "GET",**
**headers: {**
**"X-Shopify-Access-Token": accessToken,**
**"Content-Type": "application/json"**
**}**
**});**
**if (!storeInfoRes.ok) {**
**const storeInfoErrorRes = await storeInfoRes.text();**
**throw new Error(\`Failed to fetch store info! status: ${storeInfoRes.status}\`);**
**};**
**const storeInfoData = await storeInfoRes.json();**
**const email = storeInfoData.shop.email;**
**const redirectUrl = \`${app_url}/Shopify.html?shop=${shop}&accessToken=${accessToken}&email=${email}\`;**
**return res.redirect(redirectUrl);**
} catch (error) {
**console.log(error);**
**return res.status(500).send("Authentication failed. Try again, genius.");**
}
**});
**
Kindly help me out. Got stuck for 5 days.
My App is non-embedded public app.
