如何生成oauth_signature intuit ipp QBO API V3

Cha*_*son 5 c# oauth intuit-partner-platform

我遇到了一些.NET SDK限制的问题,因此我想发出自己的API调用并解析JSON结果.我坚持打造概括的授权头参数oauth_signature 这里.

对于此参数,它指出: 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
            );
        }
Run Code Online (Sandbox Code Playgroud)

nim*_*ava 1

请查看 Intuit 为 V3 提供的示例应用程序。这已经实施了。您可以设置按键并进行调试-

https://github.com/IntuitDeveloperRelations/

当您使用 IPP 生成应用程序时,您必须拥有消费者密钥和消费者秘密。这就是您提到的行中所提到的内容。

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

对于其他问题,只需在 web.config 中设置应用程序密钥后调试示例代码即可得到答案。