How to sign an API request for Quickbooks online books in ColdFusion 9?

In my CF application, I used CF OAuth code in riaforge to get the token and access token from QuickBooks Online, and it works well. After I tried to make the QBO API call, starting to build the http headers for the call (I followed the instructions in the "HTTP Authorization Header" section here: Implement OAuth in your application ). Then he built an http header based on the code methods in riaforge because it worked. In addition, I followed the order of the parameters specified by Intuit in the previous link).

When I launched the API call, I got a response: "signature_invalid"

I really need directions on how to sign a QBO online API call with CF 9 if I have 6 header options:

  • oauth_token
  • oauth_nonce
  • oauth_consumer_key
  • oauth_signature_method
  • oauth_timestamp
  • oauth_version

(But if possible, working code will be better)

Thank you in advance for your time and help.

+3
source share
1 answer

this is what I use to create the signature and title for the request token, simple add-ons are used for other signatures that you will need along the way.

paramsStr = "oauth_callback=" & encodeData(CALL_BACK_URL) & "&" & "oauth_consumer_key=" & sConsumerKey & "&" & "oauth_nonce=" & session.nonce & "&" & "oauth_signature_method=" & SIGNMETHOD & "&" & "oauth_timestamp=" & TIMESTAMP & "&" & "oauth_version=" & VERSION;

signStr = "POST&" & encodeData(REQUEST_TOKEN_URL) & "&" & encodeData(paramsStr);

signature = computeHMACSignature(signStr, sConsumerSecret & "&");

authHeader = 'OAuth ' & createHeaderElement("oauth_consumer_key", trim(sConsumerKey)) & ", " & createHeaderElement("oauth_nonce", trim(session.nonce)) & ","  & createHeaderElement("oauth_signature_method", trim(signmethod)) & ", " & createHeaderElement("oauth_signature", trim(signature)) & ", " & createHeaderElement("oauth_timestamp", trim(TIMESTAMP)) & ", " & createHeaderElement("oauth_version", trim(VERSION)) & ", " & createHeaderElement("oauth_callback", trim(CALL_BACK_URL)); 
0
source

All Articles