Ahmed
Ahmed

Reputation: 51

how to generate access token on Shopify app without session

I develop a Shopify app and I used cookies based authentication for that.

sample code

server.use(session({ secure: true, sameSite: 'none' }, server));
server.use(
    createShopifyAuth({
      apiKey: SHOPIFY_API_KEY,
      secret: SHOPIFY_API_SECRET_KEY,
      scopes: ['read_products', 'write_products', 'read_themes', 'write_themes', 'read_script_tags', 'write_script_tags'],
      async afterAuth(ctx) {
        const { shop, accessToken } = ctx.session;
        
        ctx.cookies.set('shopOrigin', shop, {
          httpOnly: false,
          secure: true,
          sameSite: 'none'
        });
        
       // await login(ctx, accessToken, shop);
       // await getScriptTag(ctx, accessToken, shop);
      },
    }),
)

Now, my problem is that it doesn't work on some browsers for cookies problems.

How can I use createShopifyAuth for generating access token without using cookies. if I comment server.use(session({ secure: true, sameSite: 'none' }, server)); it doesn't work any more.

Upvotes: 0

Views: 597

Answers (1)

Onkar
Onkar

Reputation: 2584

I think you need to check the new JWT auth for cookies less authentication into the Shopify app.

Shopify Wiki Link

Upvotes: 0

Related Questions