Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello Experts,

I've been assigned to an application which will download the order details from a Magento Website using REST API. the REST API on Magento implements OAuth verification and authorization system to service all the api requests. Being a new guy with OAuth I'm just stuck where to start and how to make it done. I'm digging oauth.net and also have done googling at extent but couldn't find a solution to go ahead. Sample is available on Magento wiki but that's in PHP and my hands are not on that. If anyone knows how to do this then please, help me.

What I've tried so far is :

using System;
using System.Net;
using System.Web;
using OAuth;



namespace Magento_REST_Client
{
    class Program
    {
        static void Main(string[] args)
        {
            string ConsumerKey = "xxxxxxxxxxxxxxxxxxxxxxxxx";
            string ConsumerSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxx";


            string StoreURL = "http://dwcube.com/ma";
            string RequestTokenEndPoint = StoreURL + "/oauth/initiate";
            string CustomerAuthorizationEndPoint = StoreURL + "/oauth/authorize";
            string AdminAuthorizationEndPoint = StoreURL + "/admin/oauth_authorize";
            string accesstokenEndPoint = StoreURL + "/oauth/token";

            OAuthBase oAuth = new OAuthBase();
            string nonce = oAuth.GenerateNonce();
            string timeStamp = oAuth.GenerateTimeStamp();
            string parameters;
            string normalizedUrl;
            string Signature = oAuth.GenerateSignature(new Uri(RequestTokenEndPoint), ConsumerKey, ConsumerSecret, string.Empty, string.Empty, "GET", timeStamp, nonce, out normalizedUrl, out parameters);
            Signature = HttpUtility.UrlEncode(Signature);


            string requestURL = RequestTokenEndPoint + "?oauth_calback=http://www.demoapp.com/test&oauth_consumer_key=" + ConsumerKey + "&oauth_consumer_secret=" + ConsumerSecret + "&oauth_nonce=65454646&oauth_signature_method=HMAC-SHA1&oauth_signature=" +Signature+ "&oauth_timestamp=" +timeStamp+ "&oauth_version=1.0";

            WebRequest request = WebRequest.Create(requestURL);
            WebResponse resp = request.GetResponse();

	}
       }
}


Regards,
Sunny.
Posted
Updated 4-Dec-17 1:01am
v2
Comments
ZurdoDev 19-Jul-12 8:13am    
I would think Magento could give you a sample for C#.
Sunny_Kumar_ 19-Jul-12 8:23am    
thanks for the suggestion :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900