Changing from cookies to session based OAuth not working for me

New Member
1 0 2

I've been struggling with a react/ node js embedded public app that I'm developing, which was working fine using cookies based OAuth.  I'm following the OAuth Token tutorial to use session authentication instead.  When I type require/import statements node requres me to use ES6 import statements, so I let VS Code make the changes from:

  • require('isomorphic-fetch');
  • const dotenv = require('dotenv');
  • const Koa = require('koa'); const next = require('next');
  • const { default: createShopifyAuth } = require('@shopify/koa-shopify-auth');
  • const { verifyRequest } = require('@shopify/koa-shopify-auth');
  • const { default: Shopify, ApiVersion } = require('@shopify/shopify-api');

to :

  • import 'isomorphic-fetch';
  • import { config } from 'dotenv';
  • import Koa from 'koa';
  • import next from 'next';
  • import { default as createShopifyAuth } from '@shopify/koa-shopify-auth';
  • import pkg from '@shopify/koa-shopify-auth';
  • const { verifyRequest } = pkg;
  • import { default as Shopify, ApiVersion } from '@shopify/shopify-api';
  • import Router from 'koa-router';

I had a bit of a problem with the verifyRequest, node was erroring with 'the requested module was not found':

  • import { verifyRequest } from '@shopify/koa-shopify-auth';
  •          ^^^^^^^^^^^^^
  • SyntaxError: Named export 'verifyRequest' not found. The requested module '@shopify/koa-shopify-auth' is a CommonJS module, which may not support all module.exports as named exports.
  • CommonJS modules can always be imported via the default export, for example using:
  • import pkg from '@shopify/koa-shopify-auth';
  • const { verifyRequest } = pkg;

I used the example workaround and that seems to work.  However when I get to initialize the Shopify library part:

  • Shopify.Context.initialize({
  • API_KEY: process.env.SHOPIFY_API_KEY,
  • SCOPES: process.env.SHOPIFY_API_SCOPES.split(","),
  • HOST_NAME: process.env.SHOPIFY_APP_URL.replace(/https:\/\//, ""),
  • API_VERSION: ApiVersion.October20,
  • IS_EMBEDDED_APP: true,
  • SESSION_STORAGE: new Shopify.Session.MemorySessionStorage(),
  • });

Node errors out with:

  • Shopify.Context.initialize({
  • TypeError: Cannot read property 'initialize' of undefined

I am at a complete loss to figure out why the library initialization is not working for me.  My .env is configured correctly as I have been successful at displaying the named variables in console.log.

Any suggestions on where to look would be most welcome. 


New Member
1 0 0

Hi Mike,

I have the exactly same issue that you met, may I know did you solve it or not?

I look around the documents and some other similar issue on other tools, it seems like we miss some arguments to Shopify.Context.initialize, so it causes the error.

Unfortunately, I can't figure out what's the key points we missed.

Hope you or other developers have an idea of this issue.


6 1 2

Just ran into the same issue while trying to move away from cookies. Would love to hear if someone else who ran into this found a solution.

9 0 2

According to this 

Shopify object is imported like that:

import Shopify, {ApiVersion} from '@shopify/shopify-api';


If using require the syntax should be

const Shopify = require('@shopify/shopify-api').Shopify
const {ApiVersion} = require('@shopify/shopify-api');