MONEI / Shopify-api-node

Node Shopify connector sponsored by MONEI
https://monei.com/shopify-payment-gateway/
MIT License
952 stars 280 forks source link

Basic requests pending indefinitey on v3.0+ #370

Closed jamieowen closed 4 years ago

jamieowen commented 4 years ago

Not sure if this is me going crazy with too much Covid-19 lockdown but....

The most simplest of usages are not working for me on v3.0.0+. When I downgrade to v2.25.1 they work fine.

Access Tokens are definitely correct. All launched directly in node.. with node version v13.10.1

const Shopify = require('shopify-api-node');

const shopify = new Shopify({
  shopName:'XXXXXX',
  accessToken: 'XXXXXX,
});

shopify.shop.get().then(res=>{
  console.log( 'Done',res );
}).catch(err=>{
  console.log( 'Error',err );
});

function wait () {
  setTimeout(wait, 1000);
};
wait();

Isolating got fails as well ( using the same dependency ):

const got = require('got');

const url = 'https://XXXXX/admin/api/2020-04/shop.json';
const main = async () => {
  try{
    const res = await got(url,{
      headers:{
        "X-Shopify-Access-Token":"XXXXX"
      }
    });
    console.log( 'Done',res);
  }catch(err){
    console.log( 'Error',err );
  }
}

main();

function wait () {
    setTimeout(wait, 1000);
};

wait();

They basically hang at the Promise... and stay in the pending state. Any ideas?

paragopinath commented 4 years ago

@jamieowen are you trying to create a public app or just trying to connect to one specific shop via private app?

jamieowen commented 4 years ago

@paragopinath one specific shop via a private app..

paragopinath commented 4 years ago

@jamieowen You will need to initiate the client with shop name, API key and password if you are using private app.

const shopify = new Shopify({
  shopName: 'your-shop-name',
  apiKey: 'your-api-key',
  password: 'your-app-password'
});

Let me know is this works.

jamieowen commented 4 years ago

Hi @paragopinath

Hi yes definitely tried these combinations. But i can assure you i still get issues. And downgrading seems to be the only solution for me - the combination of access token vs apiKey/password didn't make much difference.

I had intended to use graphQL anyway - so am using the apollo client on the server now which is fine using just the X-Shopify-Access-Token header.

It really must be some weirdness with my npm/node setup - as this is a simple thing. But i haven't got much more time to spend digging.... thought i would note it here anyway!

Cheers

jamieowen commented 4 years ago

Hi @paragopinath,

I did double check with the shopify docs and it does mention you can use either : https://shopify.dev/tutorials/authenticate-a-private-app-with-shopify-admin

But both can be used via headers but obviously only apiKey/pass for Basic Auth

But i can see that this api is using basic auth on the apiKey/pass option..

jbgrunewald commented 4 years ago

I'm having a similar issue on the 3.3.1 version with node 12.16.1. For some reason requests that worked in 2.25.x are suddenly timing out.

satyavh commented 4 years ago

Just installed this library. All requests timeout for v3.3.1 Switched to v2.25.1 and everything works fine.

lpinca commented 4 years ago

@satyavh please continue on https://github.com/MONEI/Shopify-api-node/issues/371.