Hello
I’m developing an APP for my company’s shopify store to manage product subscriptions, and need to show the list of ACTIVE SubscriptionContracts.
- I already have access to the Subscriptions API in the Partners dashboard and I’m using the following scopes:
“customer_write_own_subscription_contracts,read_customer_payment_methods,read_orders,write_customers,write_own_subscription_contracts,write_products”
-
My app is currently in development, so I haven’t selected a Distribution method yet.
-
When I run my app and go to the given http://localhost:3457/graphiql enviroment, I can retrieve the SubscriptionContracts using the following query with the 2024-10 API version:
query GetSubscriptionContracts{
subscriptionContracts(first: 20, reverse:true, query: "status:ACTIVE"){
edges {
node {
id
status
customer {
id
email
}
nextBillingDate
createdAt
updatedAt
billingPolicy{
interval
intervalCount
minCycles
maxCycles
}
status
lines(first:5) {
nodes{
id
productId
variantId
}
}
}
}
}
}
But, when try to execute the request inside my app I’m getting the following error:
"Access denied for subscriptionContract field. Required access: the `read_own_subscription_contracts` or `write_own_subscription_contracts` scope."
This is the code I’m using to fetch the subscription contracts:
const response = await fetch("https://storename.myshopify.com/admin/api/2024-10/graphql.json", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Shopify-Access-Token": SHOPIFY_ACCESS_TOKEN,
},
body: JSON.stringify({
query: `
query GetSubscriptionContracts{
subscriptionContracts(first: 20, reverse:true, query: "status:ACTIVE"){
edges {
node {
id
status
customer {
id
email
}
nextBillingDate
createdAt
updatedAt
billingPolicy{
interval
intervalCount
minCycles
maxCycles
}
status
lines(first:5) {
nodes{
id
productId
variantId
}
}
}
}
}
}
`,
}),
});
Why the query works on http://localhost:3457/graphiql and NOT on my side?
I’ll appreciate any help on this issue. I have read related posts and Shopify documentation but didn’t a solution.
Thanks in advance!