FROM CACHE - en_header

Oauth error invalid_request: Could not find Shopify API application with api_key

86 4 18

I originally created my app using the React Node Tutorial. Everything worked fine and then I made a copy of the project and built a new app that needed read_order, write_order scopes to be added. I added these and tried to authenticate my new app. It seemed to be using the old API_KEY instead of the new one. So I went and deleted the earlier app from my Shopify Partner page and tried authenticating again. Now I am getting this Oauth error which looks like Shopify is still trying to use the old api_key. 

I searched my entire project and there is no reference to that earlier api_key. I closed all browsers, closed the IDE, restarted computer and same error. 

The error is: 


My server.js page: 

const dotenv = require('dotenv');
const Koa = require('koa');
const next = require('next');
const { default: createShopifyAuth } = require('@shopify/koa-shopify-auth');
const { verifyRequest } = require('@shopify/koa-shopify-auth');
const session = require('koa-session');

const { default: graphQLProxy } = require('@shopify/koa-shopify-graphql-proxy');
const { ApiVersion } = require('@shopify/koa-shopify-graphql-proxy');

const port = parseInt(process.env.PORT, 10) || 3000;
const dev = process.env.NODE_ENV !== 'production';
const app = next({ dev });
const handle = app.getRequestHandler();

const { SHOPIFY_API_SECRET_KEY, SHOPIFY_API_KEY } = process.env;

app.prepare().then(() => {

    const server = new Koa();
    server.use(session({ secure: true, sameSite: 'none' }, server));
    server.keys = [SHOPIFY_API_SECRET_KEY];

          apiKey: SHOPIFY_API_KEY,
          secret: SHOPIFY_API_SECRET_KEY,
          scopes: ['read_products', 'write_products', 'read_orders, write_orders', 'read_draft_orders', 'write_draft_orders'],
          afterAuth(ctx) {
            const { shop, accessToken } = ctx.session;
            ctx.cookies.set('shopOrigin', shop, {
                httpOnly: false,
                secure: true,
                sameSite: 'none'

    console.log("APIKEY:" + server.apiKey);
    console.log("SCOPE:" + server.scopes);

    server.use(graphQLProxy({version: ApiVersion.October19}))
    server.use(async (ctx) => {
      await handle(ctx.req, ctx.res);
      ctx.respond = false;
      ctx.res.statusCode = 200;

    server.listen(port, () => {
        console.log(`> Ready on http://localhost:${port}`);


 I checked the app settings page and the new api_key is what I have set in my .env page. 

How is Shopify still referencing this earlier api_key. Any way to resolve this issue? 

Replies 0 (0)