GraphQL error: access denied for Orders

Solved
Highlighted
New Member
2 0 0

I got this error to fetch orders with '@shopify/koa-shopify-auth'.

[GraphQL error: access denied

The query is like this.

query {
  orders(first:2) {
    edges {
      node {
        id
        name
      }
    }
  }
}

I set below scopes.

  server.use(
    createShopifyAuth({
      apiKey: SHOPIFY_API_KEY,
      secret: SHOPIFY_API_SECRET_KEY,
      scopes: [
        'read_products','write_products',
        'read_orders', 'write_orders', 'read_all_orders',
        'read_script_tags', 'write_script_tags'
      ],
      afterAuth(ctx) {
        const { shop, accessToken } = ctx.session;
        ctx.cookies.set('shopOrigin', shop, {
          httpOnly: false,
          secure: true,
          sameSite: 'none'
        });
        ctx.redirect('/');
      },
    }),
  );

Wheareas I could get products info. In addition, I could get orders information via GraphiQL App.

I researched the problem, I couldn't get any clues. Do you have same problem?

0 Likes
Highlighted
Shopify Staff
Shopify Staff
464 57 91

This is an accepted solution.

Hey @viving,

Has your app been approved for the read_all_orders scope? If this scope hasn't been approved and the first 2 orders in this store are > 60 days old, I believe this can cause the error you're seeing. You can test by querying an individual order that's less than 60 days old, or try your same query again with orders(first: 2 reverse: true).

If that doesn't explain it, please provide the x-request-id value from the response headers of your call, and I'll use this to get more info from our logs.

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

1 Like
Highlighted
New Member
2 0 0

Hey JB,

I could do it.

There were 2 problems.

First one is the cause that you mentioned.

Secound one is that I needed to restart and upload my app after changing permission.

Thanks man!

0 Likes