Advertisement
IDNPeterL

DevDefined - Get QBD Vendors

Aug 12th, 2012
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.40 KB | None | 0 0
  1. //using DevDefined.OAuth.Consumer;
  2. //using DevDefined.OAuth.Framework;
  3.  
  4. protected void GetVendors()
  5. {
  6.     OAuthConsumerContext consumerContext = new OAuthConsumerContext
  7.     {
  8.         ConsumerKey = ConfigurationManager.AppSettings["consumerKey"].ToString(),
  9.         SignatureMethod = SignatureMethod.HmacSha1,
  10.         ConsumerSecret = ConfigurationManager.AppSettings["consumerSecret"].ToString()
  11.     };
  12.  
  13.     OAuthSession oSession = new OAuthSession(consumerContext, "https://oauth.intuit.com/oauth/v1/get_request_token",
  14.                             "https://workplace.intuit.com/Connect/Begin",
  15.                             "https://oauth.intuit.com/oauth/v1/get_access_token");
  16.  
  17.     oSession.ConsumerContext.UseHeaderForOAuthParameters = true;
  18.  
  19.     oSession.AccessToken = new TokenBase
  20.     {
  21.         Token = Session["accessToken"].ToString(),
  22.         ConsumerKey = ConfigurationManager.AppSettings["consumerKey"].ToString(),
  23.         TokenSecret = Session["accessTokenSecret"].ToString()
  24.     };
  25.  
  26.     IConsumerRequest conReq = oSession.Request();
  27.     conReq = conReq.Get();
  28.     conReq = conReq.ForUrl("https://services.intuit.com/sb/vendor/v2/508053445");
  29.     try
  30.     {
  31.         conReq = conReq.SignWithToken();
  32.     }
  33.     catch (Exception ex)
  34.     {
  35.         throw ex;
  36.     }
  37.  
  38.     string header = conReq.Context.GenerateOAuthParametersForHeader();
  39.  
  40.     string serviceResponse = conReq.ReadBody();
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement