How to create oauth_signature intuit ipp QBO API V3

I'm having some problems with the .NET SDK limitations, so I would like to issue my own API calls and parse the JSON results. I am stuck on creating an oauth_signature authorization header parameter as described here .

For this parameter, it indicates: Contains the value generated by running all other request parameters and two secret values through a signing algorithm

  • Does the "two secret values" point to OAuthAccessTokenSecret and userSecret?
  • Does "all other query parameters" mean the values ​​of these parameters? Linked?
  • How do you use 2 secret values ​​in the HMACSHA1 signature algorithm? All the examples that I see just use one

What I still have.

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
            );
        }
+4

Source: https://habr.com/ru/post/1528817/


All Articles