Shopify / shopify-marketplaces-admin-app

MIT License
38 stars 45 forks source link

TypeError: Cannot read properties of null (reading 'storefrontAccessToken') #31

Closed Louis-Ni closed 1 year ago

Louis-Ni commented 1 year ago

i have followed the instruction by marketplace-kit then i started the service. i saw a link of ngrok then i click it, the page showcases the App install and ask for permission.

after this step then i tried to access the link of ngrok the error show up like below image

is that my mistake or something? how can i solve this

Karen-boop commented 1 year ago

Hi there, thanks for opening an issue. When the ngrok link was clicked did you install the app on a test store? If so then you can access the app via the admin of that test store.

cma93 commented 1 year ago

@Karen-boop for some reason this started to happen today. Earlier it worked as you said to go but now for some reason most of the time it's happening and the reason is CreateStoreFrontAccessToken Or GetStoreFrontAccessToken functions are returning null for some reason.

Louis-Ni commented 1 year ago

@Karen-boop yes, i clicked the ngrok link, it just happened i don't know why, how could i solve it? actually, it has a previous step that showed the app could not create auth token, it's not working whether i reinstall the app or re-create the project

cma93 commented 1 year ago

Well, just checked it's working in this repository. My modified project is causing this problem. Not sure why yet, but this repository doesn't have that error.

cma93 commented 1 year ago

In case anyone can help me with the problem.

I'm added all of these scopes stated below but still getting the following error: Screenshot (29)

read_products,write_products,unauthenticated_read_content,unauthenticated_read_customer_tags,unauthenticated_read_product_tags,unauthenticated_read_product_listings,unauthenticated_write_checkouts,unauthenticated_read_checkouts,unauthenticated_write_customers,unauthenticated_read_customers

Karen-boop commented 1 year ago

Have you reinstalled / updated the app after changing the scopes?

cma93 commented 1 year ago

Well, I did at least but didn't work

cma93 commented 1 year ago

I was able to fix the issue that I had. Was missing couple scopes

Louis-Ni commented 1 year ago

@Karen-boop any suggestions? it does not work as flowing the doc

cma93 commented 1 year ago

@Louis-Ni can you share what you wrote in .env files and package.json file as well? I might be able to help!

Louis-Ni commented 1 year ago

@cma93 yes how can i send to u?

cma93 commented 1 year ago

Just comment here. And with those please also share console log from the browser as well if you get the error mentioned above while trying to open the browser.

Louis-Ni commented 1 year ago

@cma93 here is the file, .env SHOPIFY_API_KEY=19ebef376fe31f78xxxxxxxxxxxxxxx SHOPIFY_API_SECRET=33e5605c36f4fxxxxxxxxxxxxxxxx SHOP=marketplace-store-02.myshopify.com SCOPES=write_products,write_customers,write_draft_orders,unauthenticated_read_product_listings,read_product_listings HOST=https://5794-61-xxx-xxx-227.ngrok.io

package.json { "name": "shopify-marketplaces-admin-app", "version": "1.0.0", "main": "index.js", "license": "MIT", "scripts": { "build": "webpack --mode production", "start": "NODE_ENV=production babel-node server/index.js", "dev": "nodemon --exec babel-node server/index.js --watch server/", "lint": "eslint --ext .js,.jsx ./", "test": "NODE_ENV=test jest" }, "engines": { "node": "^16.13.1" }, "resolutions": { "node-gyp": "9.0.0" }, "dependencies": { "@apollo/client": "^3.5.6", "@babel/core": "^7.16.0", "@babel/node": "^7.16.0", "@babel/preset-env": "^7.16.4", "@babel/preset-react": "^7.16.0", "@shopify/admin-graphql-api-utilities": "^1.0.5", "@shopify/app-bridge": "^2.0.5", "@shopify/app-bridge-react": "^2.0.5", "@shopify/app-bridge-utils": "^2.0.5", "@shopify/channels-ui": "^1.0.3", "@shopify/polaris": "^9.18.0", "@shopify/polaris-icons": "^4.12.0", "@shopify/shopify-api": "^2.0.0", "apollo-server-express": "^3.6.0", "babel-loader": "^8.2.3", "connect-history-api-fallback": "^1.6.0", "core-js": "^3.20.2", "css-loader": "^6.5.1", "dotenv": "^10.0.0", "express": "^4.17.1", "file-loader": "^6.2.0", "graphql": "^16.1.0", "html-webpack-plugin": "^5.5.0", "nodemon": "^2.0.15", "path": "^0.12.7", "react": "^16.14.0", "react-dom": "^16.14.0", "react-hot-loader": "^4.13.0", "react-router-dom": "^6.0.2", "regenerator-runtime": "^0.13.9", "sequelize": "^6.12.0-beta.1", "sequelize-cli": "^6.3.0", "sqlite3": "^5.0.2", "style-loader": "^3.3.1", "webpack": "^5.65.0", "webpack-cli": "^4.9.1", "webpack-dev-middleware": "^5.2.2", "webpack-hot-middleware": "^2.25.1" }, "devDependencies": { "@graphql-eslint/eslint-plugin": "^3.8.0", "apollo-server-integration-testing": "^3.0.0", "babel-jest": "^27.5.1", "eslint": "^8.4.1", "eslint-plugin-jest": "^26.0.0", "eslint-plugin-prettier": "^4.0.0", "eslint-plugin-react": "^7.27.1", "jest": "^27.4.7", "prettier": "^2.5.1", "umzug": "^3.0.0" }, "babel": { "presets": [ "@babel/preset-env" ] } } browser log from google chrome:

image
cma93 commented 1 year ago

@Louis-Ni I believe you ran this command after install all the packages: npx sequelize-cli db:migrate (if not please run it)

But actually, by checking your log, I need to see one more thing: Can you go to create-storefront-access-token and get-storefront-access-token files and console. log the response before returning it? you will need it to print the response of callShopifyGraphqlAPI function in both files. Print the resp variable right after the call.

Louis-Ni commented 1 year ago

@cma93 image it's null from this console log when i created an access token

Louis-Ni commented 1 year ago

@cma93 do you have an email or something? we may discuss this more efficiency

cma93 commented 1 year ago

I have but let’s give it a last shot. You need to print whole body of resp. Try this: console.log(JSON.stringify(resp.body));

On Sun 23. Oct 2022 at 11.39 AM, Louis-Ni @.***> wrote:

@cma93 https://github.com/cma93 do you have an email or something? we may discuss this more efficiency

— Reply to this email directly, view it on GitHub https://github.com/Shopify/shopify-marketplaces-admin-app/issues/31#issuecomment-1288052827, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIEPZSJ7A3BJ7MDWZMQPAF3WET2UJANCNFSM6AAAAAARGUGWTM . You are receiving this because you were mentioned.Message ID: @.***>

-- Kind Regards,

Ashfaq Afzal +358452595257

cma93 commented 1 year ago

@Louis-Ni Lets close it as it's been resolved.