I am trying to build a website were I can get all my information from my Shopify store using there API.
I have downloaded the .NET example from here, and added to the config file my API Key and secret key, when I run the test application after putting in my site name it redirects me to shopify.com control panel of my store but I writes on the screen 'It appears that an error has occured' and it says that :
Invalid request: The Shopify API application does not support oauth
I will appropriate it if any one can please try helping me and direct me to find the problem.
Thank you
Private apps don't require an OAuth access token for authentication, you can use a api-key, password combination.
for ex: https://API-KEY:[email protected]/admin/orders.xml
As kobe says, private apps are much simpler. Here's an example:
public string GetCustomers()
{
const string url = "https://your-store.myshopify.com/admin/customers.json";
var req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "GET";
req.ContentType = "application/json";
req.Credentials = GetCredential(url);
req.PreAuthenticate = true;
using (var resp = (HttpWebResponse)req.GetResponse())
{
if (resp.StatusCode != HttpStatusCode.OK)
{
string message = String.Format("Call failed. Received HTTP {0}", resp.StatusCode);
throw new ApplicationException(message);
}
var sr = new StreamReader(resp.GetResponseStream());
return sr.ReadToEnd();
}
}
private static CredentialCache GetCredential(string url)
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
var credentialCache = new CredentialCache();
credentialCache.Add(new Uri(url), "Basic", new NetworkCredential("your-api-key", "your-password"));
return credentialCache;
}
Get the credentials by going to http://your-store.myshopify.com/admin/apps, and clicking "Create a private API key" at the bottom.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With