OAuth error: Received invalid shop argument

HarshPanday
Shopify Partner
4 0 0

So I am trying to access my shopify store using the shopify admin API in node.js.
Here is how I have initialized the api
```

const { shopifyApi,ApiVersion } = require('@shopify/shopify-api');
require('@shopify/shopify-api/adapters/node');

const shopify = shopifyApi({
    apiKey: 'XXXX',
    apiSecretKey:'XXXX',
    scopes: ['read_products'],
    hostName: 'localhost:3000',
    shop:'XXX.myshopify.com',
    apiVersion: ApiVersion.July22,
  });

app.get('/auth', async (req, res) => {
    try{
    await shopify.auth.begin({
        shop: shopify.utils.sanitizeShop(req.query.shop, true),
        callbackPath: '/auth/callback',
        isOnline: false,
        rawRequest: req,
        rawResponse: res,
    });}
    catch(e){
        console.log(e)
    }
});

```
But I am getting the following error

InvalidShopError: Received invalid shop argument at Object.sanitizeShop (XXXX\node_modules\@shopify\shopify-api\lib\utils\shop-validator.js:15:19)
at XXXX\index.js:37:29
at Layer.handle [as handle_request] (XXXX\node_modules\express\lib\router\layer.js:95:5)
at next (XXXX\node_modules\express\lib\router\route.js:144:13)
\index.js:346:12)
at next (XXXX\node_modules\express\lib\router\index.js:280:10)
at expressInit (XXXX\node_modules\express\lib\middleware\init.js:40:5)

What am I doing wrong?

Replies 2 (2)

soshdev
Visitor
1 0 0

Hey, Did You solved this? I am getting the same error

HarshPanday
Shopify Partner
4 0 0

No, I didn't solve it.
But I started using this library MONEI/Shopify-api-node: Node Shopify connector sponsored by MONEI (github.com) instead