Could not find an OAuth cookie for shop url

Im writing an app with nestjs and Im using nestjs-shopify librray the point Im having the problem is when the user wait for some times and click on install i face with the error of Could not find an OAuth cookie for shop url {Name of store} and it will not installs but when the user click on install immediately it works correctly. is there any way to expand the expiration time so users have more times to click on install button?
as a setting im passing this data to shopify auth



export const authSetting = (
  basePath: string,
): ShopifyAuthModuleAsyncOptions => ({
  useFactory: (afterAuthHandler: AppShopifyAuthHandler) => ({
    useGlobalPrefix: true,
    basePath,
    afterAuthHandler,
  }),
  imports: [AppShopifyAuthModule],
  inject: [AppShopifyAuthHandler],
});

Hi Shahram,

Is this the library you’re using: GitHub - nestjs-shopify/nestjs-shopify: Build Shopify apps on NestJS

If so you may need to ask in the repo, this library isn’t maintained by Shopify so it will be difficult for us to determine how authentication is intended to work with it.

yes Im using this library . Thank you

Hey Liam I’m having the same issue with my app as well and I am using this Shopify API Express package: @shopify/shopify-app-express

Here is a link to the package: @shopify/shopify-app-express - npm

This is what my code looks like:

  const { MySQLSessionStorage } = require('@shopify/shopify-app-session-storage-mysql');

    //Set up Shopify API package
    const { shopifyApp } = require('@shopify/shopify-app-express');
    const shopify = shopifyApp({
        api: {
            apiKey: process.env.SHOPIFY_CLIENT_ID,
            apiSecretKey: process.env.SHOPIFY_CLIENT_SECRET,
            scopes: process.env.SHOPIFY_API_SCOPES.split(','),
            hostName: process.env.APP_URL,
            hostScheme: 'https'
        },
        auth: {
            path: '/shopify/auth',
            callbackPath: '/shopify/auth/redirect'
        },
        webhooks: {
            path: '/api/webhooks'
        },
        sessionStorage: MySQLSessionStorage.withCredentials(
          config.host,
          config.database,
          config.username,
          config.password,
          {
            connectionPoolLimit: 10,
            port: config.port || 3306,
            onError: (err) => console.error('Session DB error:', err)
          }
        ),
        
    });

//Begin Shopify Auth
 app.get(shopify.config.auth.path, shopify.auth.begin());


  app.get(
    shopify.config.auth.callbackPath,
    shopify.auth.callback(),
    authController.saveShopInfo.bind(authController),
    shopify.redirectToShopifyOrAppRoot()
  );

The interesting about this is that my app was working just fine all last week. I decided to uninstall it and re-install it so that I can update the app permissions and then ran into this issue.

Any ideas on what I might be doing wrong?
I’m not sure why OAuth cookie is missing from the Shop Url.

Hey everyone, I am leaving this comment as a note to anyone else that encounters this issue. When using the Shopify app Express template, it uses an outdated version of the Shopify OAUTH protocol.

It took me a long time to find any information on this, but I found another post in the community that shed some light on this situation:

According to the post above, Shopify is no longer maintaining their official express template. So what that means is that we need to take the time to understand how to make this work with the Shopify API library that Shopify maintains for NodeJS.

It seems like that is actively being maintained so it’ll be much more reliable than the Express Template.

Shopify now recommends that we use the Shopify CLI to set up a managed Shopify Installation to keep track of our app configuration settings and to use a Token Exchange to handle OAUTH

You can find more information about this by reading the post I linked to above.