App approval issues - App must install successfully without redirect

pear123
Visitor
2 0 0

My question / issue is very similar to this question on thread: https://community.shopify.com/c/shopify-apis-and-sdks/app-approval-issues-app-must-install-succesful... However, the question doesn't seem to have an answer. I also think that it is based on an embedded shopify app and mine is a standalone shopify app (although it has the default embed behavior). 

 

I have put my app into review but it gets disapproved because it first goes to my standalone shopify app and then the app redirects to the oauth login if not installed or to the homepage if they are installed. 

 

Here is a short screencast showing the "install app", landing on the standalone app landing page and then being redirected to the install page: https://drive.google.com/file/d/18jUb9r_VkJZqldJSoJqKVBFxWVIr4XvF/view?usp=sharing

 

And here is what I have for the app url:

 

Screen Shot 2021-11-29 at 4.49.58 PM copy.png

 

Here is the error I get from the app review team:

Screen Shot 2021-11-29 at 7.19.59 PM.jpg

I don't understand how i can "immediately" get to "https://example.myshopify.com/admin/oauth/request_grant" IF I don't know the shop name?! I have to get that information from the url params when they land on my page. that's why i do the redirect AFTER i know if i have the shop parameter etc. 

 

Order of events in my code. Using reactjs frontend with axios calls to an express backend.

 

Frontend:

-land on the shopify_login_page and on page load runs this function:

 

 

const checkShopParam = async () => {
        
        const url = window.location
        const shop = new URLSearchParams(url.search).get('shop');
        console.log("shop: ", shop);
        setInstallShop(shop)

        axios.get(`${SHOPIFY_HOST}/foo?shopName=` + installShop)
            .then(response => {
                console.log(response);
                // setAuthRoute(response.data)
                if(installShop){
                    // setTimeout(() => window.open(response.data), 50);
                    setTimeout(() => window.location.replace(response.data), 50);
                    console.log('install');
                }
                else{
                    setTimeout(() => window.location.replace(HOST), 50);
                    console.log('redirect to home page');
                }
                
                
                // response.render("usersRoutes", { Users: Users });
            })
            .catch(console.log("Error with shopify login func"));
    }

 

 

Backend:

-backend route takes the shop name and creates an authorization link which it sends as the response:

 

 

app.get('/foo', async (req, res) => {
    const shopName = req.query.shopName
    console.log('shop name: ', shopName);
    let authRoute = await Shopify.default.Auth.beginAuth(
      req,
      res,
      shopName,
      // SHOP,
      '/auth/callback',
      true,
    );
    console.log(authRoute);
    res.send(authRoute)
  }); 

 

 

 

Any help would be greatly appreciated. Let me know if you need more details

 

 

 

banned
Reply 1 (1)

pear123
Visitor
2 0 0

figured it out. had to do all the redirecting from the express backend not the reactjs frontend. makes sense

banned