Not able to authenticate private app on node api with access code

mikeacre
Tourist
12 0 2

Hello,

I am trying to create a custom app for a single store with custom options and checkout. For this I want to interact with the admin API via the' shopify-api-node'

I created an app in the partner dashboard, connected it to the correct store (it shows in the store and is listed as installed), and requested the proper scopes:

 

let url = ShopToken.generateAuthUrl(
            Meteor.settings.shopify.STORE_NAME,
            ['read_orders', 'read_customers', 'read_inventory', 'write_inventory', 'read_products', 'write_products', 'read_content'],
            nonce
        )

 

I am using the shopify-token package to help generate the access code

From there I was able to get the code and request the access token and then I do  

 

const shopify = new Shopify({
    shopName: Meteor.settings.shopify.STORE_NAME,
    apiKey: Meteor.settings.shopify.API_KEY,
    password: Meteor.settings.shopify.ACCESS_TOKEN,

});

let future = new Future()
        shopify.order
            .list({ limit: 5 })
            .then((data) => {
                console.log(data)
                future.return(data)
            })
            .catch((err) => {
                console.log('ERROR')
                future.throw(err)
            })

        return future.wait()

 

 

but I keep getting:

RequestError: Unexpected token < in JSON at position 0 in "https://{SHOP_NAME}.myshopify.com/admin/orders.json?limit=5"

I can only assume this is an authentication error but why?

msk
Excursionist
28 5 3

hello,

normally i faced this problem when i forget "double quotations" . please use "double quotations" like this  "https://{SHOP_NAME}.myshopify.com/admin/orders.json?limit=5".

and if you are using "double quotations" in your cURL then please try "single quotations".

Thanks

0 Likes
mikeacre
Tourist
12 0 2

Hey, Thank you for the reply. But I am trying to use the Node SDK so I am not making the cURL request.  It actually does work with curl requests, but I want to be able to use the node SDK for simplicity in the code. 

0 Likes
DavidFM
Tourist
4 0 0

Hi,

same problem also with Meteor, have you found a solution?

 

Thanks.

0 Likes
mikeacre
Tourist
12 0 2

My issue ended up being related to a conflict with the mailgun API. Are you using the mailgun API as well?

0 Likes
DavidFM
Tourist
4 0 0

Thanks for your reply,

 

I have updated web-push from 3.3.3 to 3.4.4 and it's work fine now

your other post helped me with "https-proxy-agent" and "agent-base" conflict.

 

Thanks again !

0 Likes
kavishatalsania
New Member
4 0 0

Hi 

I am using mailgun API and it is conflicting with shopify-api-node. Have you found any solution for that?

0 Likes
mikeacre
Tourist
12 0 2

Negative, I had to remove the mailgun SDK to get it to work, I ended up just creating an API to receive the web hook notifications on actions. . I moved on to another project and haven't had to use the two together yet. The storefront API works fine, so if you just need product and customer data you can utilize that.

0 Likes