Scopes issue when trying to publish products

I am in the process of trying to publish a product. I am using the publishablePublish mutation but getting the error that I need the “read_product_listings” scope but the documentation says I only need the “write_publications” scope which I have.

Below is the publication query I am doing:

mutation PublishProduct($productId: ID!, $publicationIds: [PublicationInput!]!) {
  publishablePublish(id: $productId, input: $publicationIds) {
    publishable{
      publishedOnCurrentPublication
    }
}
  }

Here is the error:

{
  "errors": [
    {
      "message": "Access denied for publishedOnCurrentPublication field. Required access: `read_product_listings` access scope.",
      "locations": [
        {
          "line": 152,
          "column": 7
        }
      ],
      "path": [
        "publishablePublish",
        "publishable",
        "publishedOnCurrentPublication"
      ],
      "extensions": {
        "code": "ACCESS_DENIED",
        "documentation": "https://shopify.dev/api/usage/access-scopes",
        "requiredAccess": "`read_product_listings` access scope."
      }
    }
  ],
  "data": {
    "publishablePublish": {
      "publishable": null
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 10,
      "actualQueryCost": 10,
      "throttleStatus": {
        "maximumAvailable": 2000,
        "currentlyAvailable": 1990,
        "restoreRate": 100
      }
    }
  }
}

To my knowledge “read_product_listings” is an unauthorized scope so no clue why I would need that for this mutation.

If there is a way to do this without the publishablePublish mutation I’d take that as well.

If you remove the publishedOnCurrentPublication field (and any fields that require reading the product’s publication state) from your mutation response, you can perform the publishablePublish mutation without needing read_product_listings. Right now, the presence of publishedOnCurrentPublication in your query is forcing Shopify to require that scope.

Alternatively, if you do need to read the product’s publication state, you must request the read_product_listings scope on your app in addition to the scopes you already have.

3 Likes

you’re the man. thanks. that worked.

2 Likes