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.
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!
