unauthenticated_read_product_inventory scope not applying (unable to access quantityAvailable)?

CWB2_0
Shopify Partner
2 0 0

Similar to this unresolved issue from a few months ago..

I am trying to access a Variant's inventory quantities (quantityAvailable), in order to see if a product has enough stock to be completely fulfilled (Cart quantity <= quantityAvailable), through a Custom App.

 

According to the documentation on access scopes, the unauthenticated_read_product_inventory scope is exactly what I need, but it doesn't seem to be recognized.

 

I have added those scopes to the shopify.app.toml,...

 

scopes = "read_all_orders,read_inventory,read_orders,read_products,unauthenticated_read_product_inventory,unauthenticated_read_product_listings,unauthenticated_read_product_pickup_locations,write_orders,write_payment_customizations,write_products"

 

... as well as deployed the config (and accepting the updated scopes). My Partners dashboard shows that these changes were successful.

CWB2_0_0-1716845891505.png

 

However, when trying to write a graphql query to find a variant's inventory...

 

query VariantInventory($id: ID!) {
  node(id: $id) {
    ... on ProductVariant {
      id
      currentlyNotInStock
      quantityAvailable
    }
  }
}

 

... I get the following error message:

 

{
  "data": {
    "node": {
      "id": "gid://shopify/ProductVariant/12345678901234",
      "currentlyNotInStock": false,
      "quantityAvailable": null
    }
  },
  "errors": [
    {
      "message": "Access denied for quantityAvailable field. Required access: `unauthenticated_read_product_inventory` access scope.",
      "locations": [
        {
          "line": 6,
          "column": 6
        }
      ],
      "path": [
        "node",
        "quantityAvailable"
      ],
      "extensions": {
        "code": "ACCESS_DENIED",
        "documentation": "https://shopify.dev/api/usage/access-scopes",
        "requiredAccess": "`unauthenticated_read_product_inventory` access scope."
      }
    }
  ]
}

 

 

The only thing that may help point towards any hint, is that when I list the access scopes, the unauthenticated_read_product_inventory scope doesn't appear for whatever reason.

 

query AllScopes{
  appInstallation {
    accessScopes {
      handle
    }
  }
}

## LEADS TO ##

{
  "data": {
    "appInstallation": {
      "accessScopes": [
        {
          "handle": "read_content"
        },
        {
          "handle": "read_all_orders"
        },
        {
          "handle": "write_orders"
        },
        {
          "handle": "write_payment_customizations"
        },
        {
          "handle": "write_products"
        },
        {
          "handle": "unauthenticated_read_content"
        },
        {
          "handle": "unauthenticated_read_product_listings"
        },
        {
          "handle": "read_orders"
        },
        {
          "handle": "read_payment_customizations"
        },
        {
          "handle": "read_products"
        }
      ]
    }
  },
  "extensions": {
    "cost": {
        ...
      }
    }
  }
}

 

 

So what is going wrong here? Why is the unauthenticated_read_product_inventory  scope disappearing? And what can I do to find a Variant's inventory levels?

 

Thanks in Advance!

Replies 2 (2)

tomperalta
Visitor
1 0 0

It seems this issue has been going on for months — Shopify support sucks.

CWB2_0
Shopify Partner
2 0 0

As a growing list of the supposed adding of this feature (yet still no support)...

 

  • "totalInventory will be available in the 2020-04 version of the Storefront API, and this SDK will be updated shortly after the API is publicly released. Note that you will need the unauthenticated_read_product_inventory scope to read product inventory."   - February 2020 (Github - Shopify Staff)
  • "Hello [user], this will be available in the Storefront API as of April 2020 🎉, and will be called ProductVariant.quantityAvailable! Check out the Storefront API ProductVariant API reference for 2020-04. This SDK will be updated shortly after the full release."  - February 2023 (Github - Shopify Staff (Same as Above))

  • "Need unauthenticated_read_product_inventory to access quantityAvailable? -- `availableForSale` "fix"  - February 2023 (Shopify Forum)
  • "Access denied for quantityAvailable field. Required access:unauthenticated_read_product_inventory"  - May 2023 (Shopify Forum)
  • "At this time this scope is unavailable for the Storefront API via Checkout UI extensions. I have brought this to the attention of the team. You can also create a Github Issue requesting this scope be added."  - July 2023 (Shopify Support)

  • "This is currently a limitation of the direct storefront API access for checkout UI extensions and planned to be addressed in the future. Alternatively, you can craft your own Storefront API query with an token which does have that access scope."  - December 2023 (Github)
  • "Hey [user] 👋 . The GraphiQL app doesn't support selection of unauthenticated_read_product_inventory on install. I see someone has responded to your ask over on the ui-extension repo that for ui-extensions this is something that will be fixed in the future."  - December 2023 (Github - Shopify Staff)
  • My Post  - May 2024 (Shopify Forum)

 

C'mon people, you've claimed that this works for over 4 years now. What went wrong?