Admin App not Authenticated?

While I’m a seasoned coder, I am very new to shopify app development. I created an app with 2 sub-pages from the initial framework. I’m starting with a simple graphQL query to get data on one of the locations in our store.

When I try to access the page with the query, I get this:

… each time.

Here’s the code for the page:

import { authenticate } from "../shopify.server";

// This is the server-side loader function that runs when the route is loaded
export const loader = async ({ request }) => {
  const { admin} = await authenticate.admin(request);

  const quarantineLocation = "US Quarantine";

  // Get the US Quarantine location ID
  const LOCATION_QUERY = `#graphql
    query {
      locations(first: 1, query: "name:\\"US Quarantine\\"") {
        edges {
          node {
            id
            name
          }
        }
      }
    }
  `
  const queryResult = await admin.graphql(LOCATION_QUERY);
  const locationData = await queryResult.json();
  console.log(locationData);

  return locationData;
}

I’ve registered the app with the Partners website and I believe I have granted it all permissions.

My .toml file has my scopes set correctly and I am not sure what I am doing wrong.

Any help would be very much appreciated!

Scott.

Hey @RSL_IT,

I think this may be due to the fact you are not returning the data from your loader as a response. You can try using the json utility from @remix-run/node (being deprecated) or just returning a valid Response.

Hope this helps!

Hi @RSL_IT - are you still seeing this issue?

Strangely, and I’m sure it’s my not fulling getting the authentication nuances, it comes and goes. When look at the preview initially, it no longer appears but if I walk away for a few minutes and come back, it reappears. After that, I quit and reopen the CLI and it’s gone.

So, I’m still mucking (and reading) about with the code. The good news is that that issue is no longer blocking me from moving forward, it’s just an annoyance that will have to be fixed eventually.

1 Like

Glad it’s not a blocker currently - If you’re using the boilerplate app that’s generated by the CLI then you shouldn’t need to do any manual work to set up authentication.

Indeed. However, Boilerplates were created to be messed with and that’s what I did. I am really learning and have started over a few times – looking to understand what I did wrong and moving on from there.

But it is a great starting point. I’ll get into the groove eventually. Thanks for the responses!

1 Like