Scopes for Delivery Profiles

Solved
Highlighted
Excursionist
20 0 2

Hi all,

I am doing a bit of work with the shipping profiles via GraphQL. This is my first time working with GraphQL but I have had some success doing basic queries using PHP and Curl. For example I am able to query and return the store name so I at least know my connection and authentication is working.

I am trying to run the query below (which works perfectly in GraphiQL) but I get an error.

$query = <<<'JSON'
query { 
	productVariant(id: "gid://shopify/ProductVariant/34644529578029") {
        id
        deliveryProfile {
          id
          name
        }
      }
}
JSON;

$post_data = array();
$post_data['query'] = $query;
$post_data = json_encode($post_data);

curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
	'Content-Type: application/json',
	'X-Shopify-Access-Token: shpca_12345678910thisIsASecret'
  )
);

$curl_response = curl_exec($curl);
curl_close($curl);
echo $curl_response;

Here is the error: 

{"data":{"productVariant":{"id":"gid:\/\/shopify\/ProductVariant\/34644529578029","deliveryProfile":null}},"errors":[{"message":"access denied","locations":[{"line":4,"column":9}],"path":["productVariant","deliveryProfile"]}],"extensions":{"cost":{"requestedQueryCost":2,"actualQueryCost":2,"throttleStatus":{"maximumAvailable":1000.0,"currentlyAvailable":998,"restoreRate":50.0}}}}

Is this a scope issue and if so what scopes do I need to set to be able to access the information I need via this app?

Thanks in advance.

0 Likes
Highlighted
Shopify Staff
Shopify Staff
582 70 127

This is an accepted solution.

Hey @garethrane,

This does appear to be a scope issue. The scope you need to access deliveryProfiles is read_shipping.

JB | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

2 Likes
Highlighted
Excursionist
20 0 2

@_JB that was indeed the issue. A simple change of the scopes and I am successfully querying the delivery profiles via GraphQL. :) 

0 Likes