Since yesterday I try to juste get a list of my products via Shopify Javascript API.
1. Shopify Javascript API
I tried to follow this tutorial: https://shopify.github.io/js-buy-sdk/
My code:
const shopClient = ShopifyBuy.buildClient({
apiKey: 'e1616e793836bd1178d34dfa124667cf',
appId: '6',
domain: 'cordillot-store.myshopify.com'
})
// fetch a product using resource id
shopClient.fetchAllProducts()
.then(function (product) {
console.log(product)
})
.catch(function () {
console.log('Request failed')
})
2. Private App instructions
So, I decided to follow the instruction after creating my private app
My code:
import request from 'superagent'
request
.get('https://e1616e793836bd1178d34dfa124667cf:c796f294364021868d7123239606146f@cordillot-store.myshopify.com/admin/products.json')
.end((error, response) => {
console.log(error)
console.log(response)
})
And I got a 401:
But, this URL works well with cURL
curl -X GET https://e1616e793836bd1178d34dfa124667cf:c796f294364021868d7123239606146f@cordillot-store.myshopify.com/admin/products.json
3. Public App
After I created a Public Application and try to connect with Oauth (https://help.shopify.com/api/guides/authentication/oauth).
Everything runs good until I tried to reach the URL 'http://[SHOP_NAME]/admin/oauth/access_token', I got an 404.
Anyone can help me?
Thank you a lot!
Hi i tried shopify javascript sdk https://shopify.github.io/js-buy-sdk/ . getting same error because of Permission in admin app. Follow the below steps fix that issue.
1) Login into shop admin page 2) Add Sales Channels as Buy Button. 3)Choose Buy Button in side menu and create new JavaScript Buy SDK token then try create token
4) Then try your code Example Code
const shopClient = ShopifyBuy.buildClient({
accessToken: '1c51f10dc2a3bd1e7dc31974cdc06aef',
appId: '6',
domain: 'shopify-deals-dev.myshopify.com'
});
shopClient.fetchAllProducts()
.then(function (product) {
console.log(product);
})
.catch(function () {
console.log('Request failed');
});