Skip to content

Unauthenticated graphql admin api request results in a GraphQL Client: Unauthorized error #884

Open
@javangriff

Description

Starting with a fresh app, making an unauthenticated admin request as below, where example.myshopify.com is the shop url of a store where the app has been successfully installed, results in a GraphQL Client: Unauthorized error.

import { ActionFunctionArgs } from "@remix-run/node";
import { unauthenticated } from "../shopify.server";

export async function action({ request }: ActionFunctionArgs) {
 const { admin } = await unauthenticated.admin("example.myshopify.com");

 const response = await admin.graphql(
   `#graphql
     mutation populateProduct($input: ProductInput!) {
       productCreate(input: $input) {
         product {
           id
         }
       }
    }`,
    { variables: { input: { title: "Product Name" } } }
  );

 const productData = await response.json();
 return json({ data: productData.data });
}

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions