Access denied for stagedUploadsCreate field

Hey, I’m tring to create an app with remix, but I can’t upload files.

import { unstable_parseMultipartFormData, unstable_createMemoryUploadHandler } from "@remix-run/node";
import { uploadFile } from "~/models/file.server";
import { authenticate } from "~/shopify.server";

export const action = async ({request}) => {   
    const { admin } = await authenticate.admin(request);
    const uploadHandler = unstable_createMemoryUploadHandler({
        maxPartSize: 5_000_000,
    });
    const formData = await unstable_parseMultipartFormData(
        request,
        uploadHandler
    );
    const file = formData.get('file');

    const fileObject = {
        filename: file.name,
        fileSize: file.size.toString(),
        mimeType: file.type,
        resource: "FILE",
        httpMethod: "POST"
      }
    
      const result = await admin.graphql(`
        mutation stagedUploadsCreate($input: [StagedUploadInput!]!) {
          stagedUploadsCreate(input: $input) {
            stagedTargets {
              url
              resourceUrl
              parameters {
                name
                value
              }
            }
          }
        }
      `, {
        variables: {
          input: [fileObject],
      }});
}

There’s an error:
GraphqlQueryError: Access denied for stagedUploadsCreate field.

I would be very grateful if someone could help me solve this problem.

To upload files, I needed to add permissions to scope in “shopify.app.toml”

scopes = "write_products,read_files,write_files"
1 Like

To whoever facing this issue,

  1. Ensure you have requested proper scopes

  2. Check in partner dashboard if its reflected

  3. Last and important step your app needs to be sales channel enabled (go to configuration).