Development discussions around Shopify APIs
hi
have unable to get data using jquery/json
it give athuntication error
any buddy help.
Thanks...
Hi chandra,
We need more context to be able to help you here. Things that will help are:
Since you mentioned jQuery it sounds like you're trying to access the secure API via storefront / theme code. The API requires authentication and should not be accessed in that way.
hi Jason,
have try to on aspx page using jquery
For Get product detail
below given code have use
<script type="text/javascript">
$(document).ready(function () {
alert("sssa");
var jsonData = {
"apikey": "[redacted]",
"Password": "[redacted]"
};
$.ajax({
type: 'GET',
dataType: 'json',
url: 'https://cstechmkweb.myshopify.com/admin/products.json',
data: jsonData,
headers: {
"Access-Control-Allow-Origin: ": "*",
},
success: function (data) {
alert("hello");
alert(JSON.stringify(data));
},
error: function () {
alert("An error occurred while processing JSON file.");
}
});
Thanks..
I edited your post to remove the secure API key and password details. I know you had been asked for code but never post those details on a public site. I would suggest that you delete that key immediately and make a new one.
As suspected, you're trying to access the Shopify API with JavaScript - likely on a page visible to the public. You should not do this as it exposes the API key and password to anyone viewing that page. I can not stress enough how bad that is from a security standpoint.
Why do you need to use the API to get that data?
What are you trying to do that can't already do on the storefront?
I'm also struggling to authenticate with Shopify.
I'm trying to get this page:
https://store.myshopify.com/admin/products.json
but what I get is:
=> {"errors"=>"[API] Invalid API key or access token (unrecognized login or wrong password)"}.
I was trying to achieve it through this:
url = 'https://'+@api_key+':'+@password+'@storename.myshopify.com/admin/products.json'
uri = URI(url)
response = Net::HTTP.get(uri)
p = JSON.parse(response)
I suspect that the method I'm using is not longer supported .. maybe I should try another method using headers or something?
User | RANK |
---|---|
10 | |
4 | |
3 | |
3 | |
3 |
We're excited to announce improvements to the threaded messaging experience in our communi...
By TyW May 31, 2023Thank you to everyone who participated in our AMA with Klaviyo. It was great to see so man...
By Jacqui May 30, 2023Photo by Marco Verch Sales channels on Shopify are various platforms where you can sell...
By Ollie May 25, 2023