I go an error for GraphQL after reinstall application

Hi,

My application work well, but I had dev an graphQL, it worked before I reinstall the application but not after.

I change the credential with the partner application credential.

The code :

import {json} from "@remix-run/node";
import {getBishop} from '~/models/Bishop.server';
import {
    getToken,
    getPartner,
    getRubriques,
} from '~/api/bishop';

import '@shopify/shopify-api/adapters/node';
import {shopifyApi, LATEST_API_VERSION} from '@shopify/shopify-api';
import { authenticate } from "~/shopify.server";
const shopify = shopifyApi({
  apiKey: '****************',
  apiSecretKey: '**************',
  scopes: ['read_products'],
  hostName: '**********************',
  apiVersion: LATEST_API_VERSION,
  isEmbeddedApp: true
});

export async function loader({request, params}) {
    const {session, admin} = await authenticate.admin(request);

    const queryString = `query {
  products(first: 100, query: "variants.price:45..55") {
    edges {
      node {
        id
        title
        images(first: 1) {
            edges {
              node {
                originalSrc
              }
            }
          }
        variants(first: 1) {
          edges {
            node {
              price
            }
          }
        }
      }
    }
  }
}`
    const client = new shopify.clients.Graphql({session});
    const requestReturn = await client.query({
        data: queryString,
    });

    return json(requestReturn.body.data.products.edges);
}

And the partner application :

And I got this error :

Unexpected Server Error Error: Received an error response (401 Unauthorized) from Shopify: ā€œ[API] Invalid API key or access token (unrecognized login or wrong password)ā€ If you report this error, please include this id: b3a26c0c-7a5a-4a80-ba16-c1fa7fabb92b

I suppose that can take some time to deploy an new API credential, but that was 12 hours ago.

Thanks a lot.

1 Like

Hi Gone-Pixel,

There could be a couple reasons why you’re seeing the ā€œInvalid API key or access tokenā€ error. Here are a few things to check:

  1. Incorrect API Key or Password: Make sure that the API key and password are correct. You mentioned that you’ve recently changed the credentials, so there’s a chance that an error could have been made while copying them.

  2. Incorrect Store URL: The error could also be due to the wrong store URL. Be sure to include the ā€˜.myshopify.com’ part of your store URL and avoid adding ā€˜https://’ or ā€˜www’ to the URL.

  3. Token Expiration: Access Tokens have an expiration time, it might be possible that your token has expired. You should implement a method to refresh the token when it expires.

  4. Permission Scope: The requested endpoint may not be included in the access scope of your app. Check your app’s access scopes in the Partner dashboard to ensure it has the necessary permissions.

  5. Propagation Delay: As you mentioned, there can be a propagation delay when you create new API credentials. If all the above points are correct, you might want to wait a little longer.

Check the above and let us know if you’re still seeing this issue.

1 Like

Yes I has already check all points :disappointed_face:

I try another way, but I got another error :

"Unexpected Server Error

TypeError: Cannot read properties of undefined (reading ā€˜statusCode’)"

The full error stack :

TypeError: Cannot read properties of undefined (reading ā€˜statusCode’) at /Users/yann/Desktop/WebstormProjects 2/bishop-shopify-app/bishop-app/node_modules/@shopify/shopify-api/adapters/node/adapter.ts:36:41 at Generator.next () at /Users/yann/Desktop/WebstormProjects 2/bishop-shopify-app/bishop-app/node_modules/tslib/tslib.js:169:75 at new Promise () at Object.__awaiter (/Users/yann/Desktop/WebstormProjects 2/bishop-shopify-app/bishop-app/node_modules/tslib/tslib.js:165:16) at nodeConvertIncomingResponse (/Users/yann/Desktop/WebstormProjects 2/bishop-shopify-app/bishop-app/node_modules/@shopify/shopify-api/adapters/node/adapter.js:21:20) at /Users/yann/Desktop/WebstormProjects 2/bishop-shopify-app/bishop-app/node_modules/@shopify/shopify-api/lib/auth/oauth/oauth.ts:72:59 at Generator.next () at fulfilled (/Users/yann/Desktop/WebstormProjects 2/bishop-shopify-app/bishop-app/node_modules/tslib/tslib.js:166:62) {stack: ā€œTypeError: Cannot read properties of undefined (re…pp/bishop-app/node_modules/tslib/tslib.js:166:62)ā€, message: ā€œCannot read properties of undefined (reading ā€˜statusCode’)ā€}

The full code is :

import {authenticate} from "~/shopify.server";
import {json} from "@remix-run/node";

export async function loader({request}) {
    const {admin} = await authenticate.admin(request);

    const response = await admin.graphql(`{
  products(first: 100 {
    edges {
      node {
        id
        title
        images(first: 1) {
            edges {
              node {
                originalSrc
              }
            }
          }
        variants(first: 1) {
          edges {
            node {
              price
            }
          }
        }
      }
    }
  }
}`);

    const responseJson = await response.json();

    return json(responseJson.body.data.products.edges);
}

And the second way (the first was working before create another app), is still not working.

I’m having this same statusCode issue during app install. This is new for me, haven’t had this problem in the last year until a few weeks ago. This issue also has discussed this problem with no response yet from Shopify.

https://github.com/Shopify/shopify-app-js/issues/484

I can send my code or whatever is helpful. But help would most certainly be appreciated!

1 Like

this is happening during the first part of the oAuth process in my ā€˜/begin’ endpoint where I am running shopify.auth.begin. Note this has been working fine for about a year and just started happening recently.

TypeError: Cannot read properties of undefined (reading ā€˜statusCode’)
at /var/task/apps/app/.next/server/app/api/shopify/uninstall/route.js:1:4687
at Generator.next ()
at /var/task/apps/app/.next/server/chunks/849.js:1:14094
at new Promise ()
at Module.h (/var/task/apps/app/.next/server/chunks/849.js:1:13843)
at t.nodeConvertIncomingResponse (/var/task/apps/app/.next/server/app/api/shopify/uninstall/route.js:1:4614)
at /var/task/apps/app/.next/server/chunks/3366.js:1:12042
at Generator.next ()
at s (/var/task/apps/app/.next/server/chunks/849.js:1:13899)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

1 Like

Hi!

Had similar problem that the proxy link stops working after reinstall - the reason was that webhook ā€œUNINSTALLEDā€ was not successfully delivered when my remix app was running locally. So it did not delete the session record related to the shop when uninstalled keeping an old token and scopes.

After I have manually deleted the record from DB and after installed the app back - it created the new record and it starts working.