How to sign a quickbooks online API request in ColdFusion 9?

浪子不回头ぞ 提交于 2019-12-10 18:55:58

问题


In my CF app, I've used the CF OAuth code at riaforge to get request token and access token from QuickBooks Online and it works fine. After I tried to make a QBO API call by starting to build the http headers of the call (I followed the instructions on the section "HTTP Authorization Header" here: Implement OAuth in Your App). Then built the http header based on the methods of the code at riaforge because it worked. In addition, I've respected the order of the parameters given by Intuit in the previous link).

When I launched the API Call, I received the response: "signature_invalid"

I really want directions on how to sign the QBO online API Call with CF 9 if I have ready the 6 header parameters:

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

(But if possible a working code would be better)

Thank you in advance for your time and help


回答1:


this is what I use for generating the signature and header for the request token, simple additions are used for the other signatures you'll 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)); 


来源:https://stackoverflow.com/questions/21827426/how-to-sign-a-quickbooks-online-api-request-in-coldfusion-9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!