-
-
Notifications
You must be signed in to change notification settings - Fork 276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Receiving error while trying to use SDK with Meteor #406
Comments
Is it resolved? I am getting the same |
No I’ve had to go back to using square for my projects for now. |
Make sure |
Thank you for the reply @lpinca , What is the password then?
Doest that mean the password is the Api Key? |
Still receiving the same error this way. But also doesn't this negate me making a private app and creating the access token? Is there no need for the access token at all then? |
I can create a simple http request using those credentials, but this does not work for the sdk. |
Yes, exactly, you don't need an access token for private apps.
I don't know, can you create test case to reproduce the issue? Something like this #386 (comment). |
This seems a duplicate of #386. |
I dont think its a duplicate.. I am able to access the API with an HTTP call using those credentials. But when I try to use the SDK i get the error, same key and secret from the private app. But I was also trying to understand how to connect a custom app, and that is why I created the access key... which also didnt work with the sdk it seemed. |
Try to run this: const Shopify = require('shopify-api-node');
const shopify = new Shopify({
shopName: 'quuz',
apiVersion: '2020-07',
apiKey: 'b68c3a4bf44cd240511e5f4114f0be4d',
password: '2d170167fc62551920ca60fe40a5e548'
});
(async function () {
const shop = await shopify.shop.get();
console.log(shop);
})().catch(console.error); does it work on your machine? If so replace the |
HTTPError: Response code 401 (Unauthorized) |
When I load in my credentials I go back to the RequestError: Unexpected token < in JSON at position 0 |
Was it run on Meteor? That stack trace is super weird. Can you try with plain Node.js? |
Hey @lpinca you are right, I am using Meteor. I ran this in plain Node and it did work without an issue. |
It also works with the access token this way, I guess the issue must be with Meteor or another package I have installed. I will have to play with it. Do you have any ideas? |
I have no clue. The package was designed for Node.js. |
@mikeacre when putting the example code from above in a new Meteor project in import Shopify from 'shopify-api-node'
const shopify = new Shopify({
shopName: 'your-shop-name',
apiKey: 'your-api-key',
password: 'your-app-password'
}) I20200820-09:19:45.633(2)? Shopify {
I20200820-09:19:45.654(2)? _events: [Object: null prototype] {},
I20200820-09:19:45.654(2)? _eventsCount: 0,
I20200820-09:19:45.654(2)? _maxListeners: undefined,
I20200820-09:19:45.654(2)? options: {
I20200820-09:19:45.655(2)? timeout: 60000,
I20200820-09:19:45.655(2)? shopName: 'your-shop-name',
I20200820-09:19:45.655(2)? apiKey: 'your-api-key',
I20200820-09:19:45.655(2)? password: 'your-app-password'
I20200820-09:19:45.655(2)? },
I20200820-09:19:45.655(2)? callLimits: { remaining: undefined, current: undefined, max: undefined },
I20200820-09:19:45.655(2)? callGraphqlLimits: {
I20200820-09:19:45.655(2)? restoreRate: undefined,
I20200820-09:19:45.655(2)? remaining: undefined,
I20200820-09:19:45.655(2)? current: undefined,
I20200820-09:19:45.655(2)? max: undefined
I20200820-09:19:45.656(2)? },
I20200820-09:19:45.656(2)? baseUrl: { hostname: 'your-shop-name.myshopify.com', protocol: 'https:' },
I20200820-09:19:45.656(2)? baseHeaders: {
I20200820-09:19:45.656(2)? 'User-Agent': 'shopify-api-node/3.4.3',
I20200820-09:19:45.656(2)? Authorization: 'Basic eW91ci1hcGkta2V5OnlvdXItYXBwLXBhc3N3b3Jk'
I20200820-09:19:45.656(2)? },
I20200820-09:19:45.656(2)? [Symbol(kCapture)]: false
I20200820-09:19:45.656(2)? } Can you please add a minimal reproduction project (with some fake API credentials, that can be replaced with some real ones) where you can reproduce the erorr(s)? Usually Meteor = Node so there should be no issue with integrating anything that is designed for node. |
OK Well I figured it out... it is the inclusion of the mailgun-js api. Once I removed that package it worked no problem. I guess I need to look into mailgun now. const mailgun = require("mailgun-js"); |
On #386 the same issue is caused by |
Here is a test case with only const mailgun = require('mailgun-js');
const got = require('got');
got(
{
hostname: 'httpbin.org',
protocol: 'https:',
pathname: '/json'
},
{
responseType: 'json',
retry: 0
}
)
.then(function (response) {
console.log(response.body);
})
.catch(console.error); See also mailgun/mailgun-js-boland#265. I think this happens because There is not much we can do about it. Can you switch to https://www.npmjs.com/package/mailgun.js? |
Had the same issue with shopify-api-node while using mailgun-js (which was last updated 2 years ago), moving over to an even more bloated package (mailgun.js) that is less maintained really wasn't an option. |
I'm closing as switching to |
But it's interesting that this shopify package is conflicting with a couple of packages. Sounds like something is not right |
Hey,
When I try to call the sdk I get the error:
"Exception while invoking method 'shop.get.customers' RequestError: Unexpected token < in JSON at position 0"
Which I assume is due to an authentication error.
I used ShopToken to generate a code and then an access token.
I am initializing the SDK as such:
`
const shopify = new Shopify({
shopName: {STORE_NAME},
apiKey: {API_KEY},
password: {ACCESS_TOKEN},
});
`
The store name is the name of the store I authenticated with the token and have the access token for.
The api key is the one in my shopify partners dashboard that shows the app has been installed and has the appropriate permissions.
The Access Token is the one I generated after making the code with the correct permissions
Any ideas what could be causing this?
The text was updated successfully, but these errors were encountered: