App reviews, troubleshooting, and recommendations
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!
Solved! Go to the solution
This is an accepted solution.
Hello Deepjpatel.
Thanks for your response.
I had installed a private app in the store with the same name as my Custom APP, and I was also using the API-Key of the private app.
To fix this, I uninstalled the private app and made sure I used the correct token.
Thanks for your support.
Hii Deep here,
I think error is scope means
Required access: the `read_own_subscription_contracts` or `write_own_subscription_contracts` scope."
This error indicates inside toml file add `read_own_subscription_contracts` & `write_own_subscription_contracts`. this two scopes and run command `shopify app deploy` so this scopes deployed on your app after you verify again that query
This is an accepted solution.
Hello Deepjpatel.
Thanks for your response.
I had installed a private app in the store with the same name as my Custom APP, and I was also using the API-Key of the private app.
To fix this, I uninstalled the private app and made sure I used the correct token.
Thanks for your support.
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024