ericdude4/shopifex

Error: Missing required scopes ["read_inventory", "read_products"], initiating app update

CliffDR opened this issue · 3 comments

Hi Eric!

First of all thank you so much for putting in all the effort in this fantastic boilerplate. Learning a ton from your work and it's very helpful now that I'm using it to build our Shopify app.

After giving it a spin per the instructions, I'm now running into the following:

Issue


I might be overlooking something simple but I keep getting the error when test installing the app:
Shop my-shop.myshopify.com is missing required scopes ["read_inventory", "read_products"], initiating app update

Even though my scopes are set with the :shopifex config settings in the config.ex. Like so:

scopes: "read_inventory,write_inventory,read_products,write_products,read_orders",

When just setting the scopes to "read_products", no errors are given.

What I've tried


I inspected ensures_scopes.ex to check what shop_scopes contained, and indeed it would online contain ["write_inventory", "write_products", "read_orders"] but not the apparently required scopes: ["read_inventory", "read_products"]

Any help or insights would be very much appreciated!

@CliffDR thanks for the kind words! Regarding your question, sometimes Shopify strips away scopes during the oauth flow if one implies the other. Then, the resulting oauth callback will only include the scopes which are left behind.

For example, if you have scopes: "read_products,write_products", Shopify will remove read_products from your oauth access token because read_products is already granted when you request write_products

Then, when the oauth callback returns to your app, it will only include write_products and ensure_scopes.ex will try the oauth flow again because read_products is missing from the store's scopes.

Does this make sense? I think if you change you scopes to the following it should solve your problems:
scopes: "write_inventory,write_products,read_orders" (since read_inventory and read_products come with their corresponding write_x scopes.

@ericdude4 That was it! I was still debugging when your super fast reply came in. Thank you so much and makes sense.

This is such a valuable boilerplate. Do you have any further development planned? Even though I'm newish to the language, would love to contribute where I can.

@CliffDR Thanks! I use this boilerplate heavily for all of my Shopify apps. I love working with it, and find myself maintaining it just in my regular usage while I work on my personal Shopify apps. I would be very interested in having more people contribute to the library - any features you write while building your Shopify app which you feel would be useful to the rest of the community would be fantastic.

However, for a specific development piece, I would like to expand the shopifex billing features to support Shopify's UsageCharges

Another piece that would be useful is an administrator panel that supported things such as:

  • logging into the app as an installed store
  • a graphiql interface for querying installed stores