Shopify / koa-shopify-auth

DEPRECATED Middleware to authenticate a Koa application with Shopify
MIT License
80 stars 63 forks source link

Context not initialize Error #132

Closed jhakeinson closed 1 year ago

jhakeinson commented 3 years ago

Issue summary

I noticed that this middleware depends on an outdated version of @shopify/shopify-api, so I installed the latest version via npm install. But when I proceeded to test/run my app. a Context has not been properly initialized error occurred.

Expected behavior

My Shopify store should install or display my app without an error.

Actual behavior

I received this error:

 Error: Context has not been properly initialized. Please call the .initialize() method to setup your app context object.
┃       at UninitializedContextError.ShopifyError [as constructor] (/home/jhake/coding/work/nils-jessen/super-test-app/node_modules/@shopify/koa-shopify-auth/node_modules/@shopify/shopify-api/dist/error.js:13:28)
┃       at new UninitializedContextError (/home/jhake/coding/work/nils-jessen/super-test-app/node_modules/@shopify/koa-shopify-auth/node_modules/@shopify/shopify-api/dist/error.js:63:42)
┃       at Object.throwIfUninitialized (/home/jhake/coding/work/nils-jessen/super-test-app/node_modules/@shopify/koa-shopify-auth/node_modules/@shopify/shopify-api/dist/context.js:66:19)
┃       at Object.<anonymous> (/home/jhake/coding/work/nils-jessen/super-test-app/node_modules/@shopify/koa-shopify-auth/node_modules/@shopify/shopify-api/dist/auth/oauth/oauth.js:38:43)
┃       at step (/home/jhake/coding/work/nils-jessen/super-test-app/node_modules/@shopify/koa-shopify-auth/node_modules/@shopify/shopify-api/node_modules/tslib/tslib.js:143:27)
┃       at Object.next (/home/jhake/coding/work/nils-jessen/super-test-app/node_modules/@shopify/koa-shopify-auth/node_modules/@shopify/shopify-api/node_modules/tslib/tslib.js:124:57)
┃       at /home/jhake/coding/work/nils-jessen/super-test-app/node_modules/@shopify/koa-shopify-auth/node_modules/@shopify/shopify-api/node_modules/tslib/tslib.js:117:75
┃       at new Promise (<anonymous>)
┃       at Object.__awaiter (/home/jhake/coding/work/nils-jessen/super-test-app/node_modules/@shopify/koa-shopify-auth/node_modules/@shopify/shopify-api/node_modules/tslib/tslib.js:113:16)
┃       at Object.beginAuth (/home/jhake/coding/work/nils-jessen/super-test-app/node_modules/@shopify/koa-shopify-auth/node_modules/@shopify/shopify-api/dist/auth/oauth/oauth.js:33:24)
┃       at /home/jhake/coding/work/nils-jessen/super-test-app/node_modules/@shopify/koa-shopify-auth/dist/src/auth/index.js:61:73
┃       at step (/home/jhake/coding/work/nils-jessen/super-test-app/node_modules/tslib/tslib.js:133:27)
┃       at Object.next (/home/jhake/coding/work/nils-jessen/super-test-app/node_modules/tslib/tslib.js:114:57)
┃       at /home/jhake/coding/work/nils-jessen/super-test-app/node_modules/tslib/tslib.js:107:75
┃       at new Promise (<anonymous>)
┃       at Object.__awaiter (/home/jhake/coding/work/nils-jessen/super-test-app/node_modules/tslib/tslib.js:103:16)

Steps to reproduce the problem

  1. Create a Shopify NodeJS app with shopify-cli.
  2. Install @shopify/shopify-api with npm install @shopify/shopify-api
  3. Run and install the app on my store with shopify node serve.
jhakeinson commented 3 years ago

I just created my own custom auth Middleware instead and stop using this one entirely.

On Sat, Nov 6, 2021, 8:43 PM Corentin Grall @.***> wrote:

Has some found a workaround ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Shopify/koa-shopify-auth/issues/132#issuecomment-962446144, or unsubscribe https://github.com/notifications/unsubscribe-auth/AI2EOXTRZJYEN5UQGOTCAY3UKUPFJANCNFSM5HCE7CMA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

azrielh commented 2 years ago

FYI: There is a thread that helped me out here by changing the version numbers: https://community.shopify.com/c/shopify-apis-and-sdks/shopify-koa-auth-importing-a-local-version-of-shopify-shopify/td-p/1114138

fukumoto-taichi commented 2 years ago

Hi! I am facing the very same problem.

I want to use the latest API version, ApiVersion.October21, but I can't because koa-shopify-auth does not support the latest @shopify/shopify-api. Is this package going to support the latest @shopify/shopify-api?

TheSecurityDev commented 2 years ago

Hi! I am facing the very same problem.

I want to use the latest API version, ApiVersion.October21, but I can't because koa-shopify-auth does not support the latest @shopify/shopify-api. Is this package going to support the latest @shopify/shopify-api?

You can use my version of this library here: https://github.com/TheSecurityDev/simple-koa-shopify-auth (There are other numerous improvements as well).

fukumoto-taichi commented 2 years ago

@TheSecurityDev Thanks for your reply. I installed your package in my project. However, when I launch my app with shopify app serve command, the app does not work with your package error.

Error: Cannot find module 'fs/promises'

What can I do to make it work properly?

TheSecurityDev commented 2 years ago

@TheSecurityDev Thanks for your reply. I installed your package in my project. However, when I launch my app with shopify app serve command, the app does not work with your package error.

Error: Cannot find module 'fs/promises'

What can I do to make it work properly?

That's strange. It's possible you need to update your version of NodeJS. But otherwise open an issue at https://github.com/TheSecurityDev/simple-koa-shopify-auth/issues

fukumoto-taichi commented 2 years ago

That's strange. It's possible you need to update your version of NodeJS. But otherwise open an issue at https://github.com/TheSecurityDev/simple-koa-shopify-auth/issues

I changed the Node.js version from 12.x to 16.x, and it worked fine 🎉 Thank you so much!!

github-actions[bot] commented 1 year ago

Note that this repo is no longer maintained and this issue will not be reviewed. Prefer the official JavaScript API library. If you still want to use Koa, see simple-koa-shopify-auth for a potential community solution.