2014-02-25 50 views
4

我遇到了一些.NET SDK限制的問題,所以想自己調用API並解析JSON結果。我堅持創建授權標頭參數oauth_signature,如here所述。如何生成oauth_signature intuit ipp QBO API V3

對於這個參數,它指出:Contains the value generated by running all other request parameters and two secret values through a signing algorithm

  1. 是否「兩個密值」是指OAuthAccessTokenSecret和consumerSecret?
  2. 「所有其他請求參數」是否意味着那些參數值?級聯?
  3. 你如何在HMACSHA1簽名算法中使用2個祕密值?我看到的所有例子只是使用一個

我到目前爲止。

public static string GetOAuthAuthorization(string oauthToken, string oauthSecret, string consumerKey, string consumerSecret) 
     { 
      string oauth_token = oauthToken; 
      string oauth_nonce = Guid.NewGuid().ToString(); 
      string oauth_consumer_key = consumerKey; 
      string oauth_signature_method = "HMAC-SHA1"; 
      int oauth_timestamp = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; 
      string oauth_version="1.0"; 

      string dataString = oauth_token + oauth_nonce + oauth_consumer_key + oauth_timestamp; 

      //TODO: use following to create oauth_signature 
      byte[] hashkey = Encoding.ASCII.GetBytes(oauthSecret); //is this one of the secret values? 
      byte[] data = Encoding.ASCII.GetBytes(dataString); 
      HMACSHA1 hmac = new HMACSHA1(hashkey); 
      byte[] result = hmac.ComputeHash(data); 

      string oauth_signature=Convert.ToBase64String(result); 

      return string.Format("OAuth oauth_token='{0}',oauth_nonce='{1}',oauth_consumer_key='{2}',oauth_signature_method='{3}',oauth_timestamp='{4}',oauth_version='{5}',oauth_signature='{6}'", 
       oauth_token, oauth_nonce, oauth_consumer_key, oauth_signature_method,oauth_timestamp,oauth_version, oauth_signature 
      ); 
     } 

回答

1

請檢查Intuit for V3提供的示例應用程序。這已經實施。你可以在你的鑰匙設置和調試 -

https://github.com/IntuitDeveloperRelations/

當你已經產生了與IPP的應用程序,你必須有一個消費者密鑰和消費者祕密。 這就是你提到的行中提到的內容。

https://developer.intuit.com/docs/0025_quickbooksapi/0010_getting_started

對於其他問題,只是調試示例代碼在web.config中在你的應用程序鍵設置後,你會得到答案。

+1

謝謝@nimisha但我不想使用SDK。我試圖找出如何直接進行API調用,而不使用SDK。所以這歸結爲做一個REST調用,我可以做。我遇到的問題是弄清楚如何填充必須位於REST調用的授權標頭中的特定字段。 –

+1

@ChadRichardson你有沒有想過這個?我們也試圖不使用SDK。 – Ryan

+1

因此,Intuit創建了一個API,但不能告訴任何人如何生成簽名來進行調用。就好像沒有人在那裏工作甚至不知道...... – Ralph

相關問題