For discussing the development and integration of subscription-enabled shops using Shopify's Subscription APIs.
Hello,
I am trying to get the subscriptionContracts using the GraphQL and I am receiving the following response:
"message": "Access denied for subscriptionContracts field.",
I see that in the response I am redirected to the Access Scopes page ( https://shopify.dev/api/usage/access-scopes ) page, but I can not find anything related to subscriptionContract, subscriptionContracts or even something related to subscriptions.
I also checked the ADMIN API PERMISSIONS section, but did not find a permission setting for subscriptions.
I want to mention that other requests, for ex. getting orders and order details, are working.
My final goal is to get a list of all subscriptions using (REST or GRAPHQL). Is this possible at this moment ? Am I doing something wrong ?
My request is build like this:
Client:
new Client([
'base_uri' => 'https://' . $shopUrl . '/admin/api/2021-10/',
'timeout' => 0,
'allow_redirects' => false,
'verify' => false,
'headers' => [
'Authorization' => 'Basic ' . base64_encode($apiKey . ':' . $pass),
'Accept' => 'application/json',
'Content-Type' => 'application/graphql'
]
]);
Body:
{
subscriptionContracts(first: 10) {
edges {
node {
id
createdAt
orders (first: 10) {
edges {
node {
id
}
}
}
}
}
}
}
The response I receive:
{
"data": null,
"errors": [
{
"message": "Access denied for subscriptionContracts field.",
"locations": [
{
"line": 3,
"column": 3
}
],
"path": [
"subscriptionContracts"
],
"extensions": {
"code": "ACCESS_DENIED",
"documentation": "https://shopify.dev/api/usage/access-scopes"
}
}
],
"extensions": {
"cost": {
"requestedQueryCost": 12,
"actualQueryCost": 2,
"throttleStatus": {
"maximumAvailable": 1000,
"currentlyAvailable": 998,
"restoreRate": 50
}
}
}
}
Solved! Go to the solution
This is an accepted solution.
I am looking in the Apps -> Manage private apps -> {APP Name} -> Admin API section.
Ah... I didn't realize it was a private app.
From the https://shopify.dev/apps/subscriptions/contracts page:
> The requirements for building an app that uses subscriptions depends on the type of app that you're building. Private apps can't access Subscription APIs. Public and custom apps need to request access to the appropriate protected scopes through the Partner Dashboard.
To learn more visit the Shopify Help Center or the Community Blog.
Hello Nelutihon,
Thank you for posting your question.
It looks like you need the read_own_subscription_contracts
access scope.
Ref: https://shopify.dev/api/admin-graphql/2021-07/objects/SubscriptionContract
Does this solve your problem?
To learn more visit the Shopify Help Center or the Community Blog.
The documentation here may help: https://shopify.dev/apps/subscriptions
Especially the sections:
You can request Shopify-Approval Scopes through the Partners Dashboard.
To learn more visit the Shopify Help Center or the Community Blog.
@MeganMcVey thank you for the quick reply.
I know about the resources that you gave, I've read them, but I can not find the specific setting that can enable or disable `read_own_subscription_contracts` access scope.
I am looking in the Apps -> Manage private apps -> {APP Name} -> Admin API section.
Can you please point me to the place where I can enable/disable the required access scopes for subscriptions ?
I am attaching the full list of access scopes.
Thank you.
This is an accepted solution.
I am looking in the Apps -> Manage private apps -> {APP Name} -> Admin API section.
Ah... I didn't realize it was a private app.
From the https://shopify.dev/apps/subscriptions/contracts page:
> The requirements for building an app that uses subscriptions depends on the type of app that you're building. Private apps can't access Subscription APIs. Public and custom apps need to request access to the appropriate protected scopes through the Partner Dashboard.
To learn more visit the Shopify Help Center or the Community Blog.
Hey,
I get this error when I use Shopify GraphiQL App