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
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));
Related
I have searched all over but can't find VBscript examples and all my attempts have failed. I need to run a Jenkins job from a classic ASP web page (VBScript). I can submit the job with the code below, but it returns a 403 crumb error. What I need to do is provide the user/password (which I have) for this job but I don't know how to setup the authentication for Jenkins in VBScript. I know the crumb error is due to CSRF (I read that much and can't turn that off) and hope that authentication will resolve that. Any help is much appreciated. Thanks in advance.
Dim strJenkinsURL, HttpReq
strJenkinsURL = "http://<jenkinsmaster>/job/<myjob>/buildWithParameters?token=test&Description="& strDesc &"&TestEnv="& testEnv
Set HttpReq = Server.CreateObject("MSXML2.ServerXMLHTTP")
HttpReq.Open "POST", strJenkinsURL, False
HttpReq.Send
Response.Write "<br>Status: "& HttpReq.Status & vbNewline
Response.Write "<br>Response: "& HttpReq.responseText & vbNewline
EDIT:
Based on comments, I attempted to add the Jenkins login information but I am still getting the 403 crumb error from Jenkins. I've tried searching for solution to getting the crumb, but haven't found any VBScript examples. Here is the code and response I am trying now but I have no idea if the setRequestHeaders are correct for Jenkins and the Jenkins documentation hasn't been any help:
Dim strJenkinsURL
strJenkinsURL = "http://<jenkins master>/job/testjob/buildWithParameters?token=test&Description="& strDesc &"&TestEnv="& testEnv
Set HttpReq = Server.CreateObject("MSXML2.ServerXMLHTTP")
HttpReq.Open "POST", strJenkinsURL, False
HttpReq.setRequestHeader "UserName", "jenkinsuser"
HttpReq.setRequestHeader "Password", "userpassword"
HttpReq.setRequestHeader "Jenkins-Crumb", "<crumbvalue>"
HttpReq.Send
Response.Write "<br>Status: "& HttpReq.Status & vbNewline
Response.Write "<br>Response: "& HttpReq.responseText & vbNewline
Status: 403
Response: HTTP ERROR 403
Problem accessing /job/testjob/buildWithParameters. Reason: No valid crumb was included in the request
For a HTTP POST request, the URL specifies the resource, i.e. strJenkinsURL = "http://<jenkinsmaster>/job/<myjob>/buildWithParameters
The parameters are added as part of the .Send command:
Dim sParams
sParams = "token=test&Description=" & strDesc & "&TestEnv=" & testEnv
HttpReq.Send(sParams)
As #Lankymart pointed out, you also need to set the appropriate headers, e.g.
HttpReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
HttpReq.setRequestHeader("Content-Length", CStr(Len(sParams)))
After piecing together many suggestions with some trial and error, I was finally able to get the Jenkins job to run remotely with the VBScript code below (with variables set to proper values such as strCrumb). The returned Status will be 201 for success. The Base64 functions were taken from Base64 Encode String in VBScript
Dim strJenkinsURL, strParam1, strParam2, strCrumb, strUsername, strPassword
strJenkinsURL = "https://<jenkinsURL>/job/testjob/buildWithParameters?token=test¶m1="& strParam1 &"¶m2="& strParam2
Set HttpReq = Server.CreateObject("MSXML2.ServerXMLHTTP")
HttpReq.Open "POST", strJenkinsURL, False
HttpReq.setOption 2, 13056
HttpReq.setRequestHeader "Jenkins-Crumb", strCrumb
HttpReq.setRequestHeader "Authorization", "Basic "& Base64Encode(strUsername &":"& strPassword)
HttpReq.Send
Response.Write "<br>Status: "& HttpReq.Status & vbNewline
Response.Write "<br>Response: "& HttpReq.responseText & vbNewline
Function Base64Encode(sText)
Dim oXML, oNode
Set oXML = CreateObject("Msxml2.DOMDocument.3.0")
Set oNode = oXML.CreateElement("base64")
oNode.dataType = "bin.base64"
oNode.nodeTypedValue = Stream_StringToBinary(sText)
Base64Encode = oNode.text
Set oNode = Nothing
Set oXML = Nothing
End Function
Private Function Stream_StringToBinary(Text)
Const adTypeText = 2
Const adTypeBinary = 1
Dim BinaryStream 'As New Stream
Set BinaryStream = CreateObject("ADODB.Stream")
BinaryStream.Type = adTypeText
BinaryStream.CharSet = "us-ascii"
BinaryStream.Open
BinaryStream.WriteText Text
BinaryStream.Position = 0
BinaryStream.Type = adTypeBinary
BinaryStream.Position = 0
Stream_StringToBinary = BinaryStream.Read
Set BinaryStream = Nothing
End Function
Reporting Services 2008 R2 Tablix Go to URL Action . . . I have the following expression . . .
="mailto:" & "email" & "?subject=" & "My Email Subject" & Fields!ReferenceNo.Value & "-" & Fields!ShortName.Value & "&body=" & "Hi," + vbcrlf + vbcrlf + "My Body Message" & Fields!ReferenceNo.Value & " - " & Fields!ShortName.Value & " " & "needs commentary." & vbcrlf & vbcrlf & "I'll be checking this later!" & vbcrlf & vbcrlf & System.Uri.EscapeDataString(""
which displays and opens an email message fine . . . however . . . replacing the "email" with Fields!Name.Value seems to make the action stop working. Any ideas?
It seems the answer to this is to start the expression as
="mailto://" & . . .
I have a website using angular.js and my backend is using asp.net web api. When a new user register a e-mail is send with an activation link and a token inside it like this :
localhost:51426/#/activation?userid=test&code=FCuuf27NzVvmwp2Ksd7IDt83C2XZmZ2paCrZPBLgr9qR8xCaXELvqKCsWlg4uiokb07XK5sQ+2BazHN1+2B74q14grkQY2OHDAVeWlin5GE8ugkyw+2BJFFzd3Q2YiVuMxkmkO6OFdhIyfzUQMV8NPipME+2FST1pa0OuQs90kRUNR5kTkPlGQYKflDOMQvDGV84fZIw
When the user click the link I have an angular controller that basically just take the parameter and call the good method inside the web.api like this :
return $http.post(baseUrl + 'api/v1/account/confirmAccount?userId=' + userId + '&code=' + code);
The problem it seems all the + are replace by space in the server side so when I try to validate the token in my web api it doesn't work.
Not sure to understand why the + it's replace by space and how to avoid this.
Thanks
The problem is that in query strings + characters are replaced by spaces:
URL Encoding:
The HTML specifies the following transformation:
SPACE is encoded as '+' or "%20" [9]
What you could do is replace the space characters with + on the server:
string newCode=code.Replace(' ','+')
One option might be to build the string first and eliminate the + altogether.
I am creating a program using the QBFC13 that is supposed to create a deposit from an other current asset type of account to a bank account. However, when the depositadd method is executed the payee doesn't get filled in on the bank account. How do i get the Payee information filled out?
I dont have a high enough reputation to post pictures so this is a link to the picture of the field i need filled out: http://i.stack.imgur.com/nqWOh.jpg
Here is my current code:
Public Sub CreateDeposit()
On Error GoTo Errs
Dim depositadd As IDepositAdd
depositadd = msgSetRequest.AppendDepositAddRq()
depositadd.DepositToAccountRef.FullName.SetValue("checking")
depositadd.Memo.SetValue("newdeposit test")
depositadd.TxnDate.SetValue(Date.Today)
Dim depositLineAdd As IDepositLineAdd
depositLineAdd = depositadd.DepositLineAddList.Append()
depositLineAdd.ORDepositLineAdd.DepositInfo.AccountRef.ListID.SetValue("1EE0000-943382783")
depositLineAdd.ORDepositLineAdd.DepositInfo.EntityRef.ListID.SetValue("80002534-1335362979")
depositLineAdd.ORDepositLineAdd.DepositInfo.Amount.SetValue(150.0)
depositLineAdd.ORDepositLineAdd.DepositInfo.Memo.SetValue("test memo lineitem")
' send the request to QB
Dim msgSetResponse As IMsgSetResponse
msgSetResponse = qbSessionManager.DoRequests(msgSetRequest)
' check to make sure we have objects to access first
' and that there are responses in the list
If (msgSetResponse Is Nothing) Or _
(msgSetResponse.ResponseList Is Nothing) Or _
(msgSetResponse.ResponseList.Count <= 0) Then
Exit Sub
End If
' Start parsing the response list
Dim responseList As IResponseList
responseList = msgSetResponse.ResponseList
MsgBox(msgSetRequest.ToXMLString())
' go thru each response and process the response.
' this example will only have one response in the list
' so we will look at index=0
Dim response As IResponse
response = responseList.GetAt(1)
If (Not response Is Nothing) Then
If response.StatusCode <> "0" Then
MsgBox("DepositFunds unexpexcted Error - " & vbCrLf & "StatusCode = " & response.StatusCode & vbCrLf & vbCrLf & response.StatusMessage)
Else
MsgBox("The funds were successfully deposited in Checking")
MsgBox(msgSetResponse.ToXMLString())
End If
End If
Exit Sub
Errs:
MsgBox("HRESULT = " & Err.Number & " (" & Hex(Err.Number) & ") " & vbCrLf & vbCrLf & Err.Description, _
MsgBoxStyle.Critical, _
"Error in DepositFunds")
End Sub
This actually isn't an SDK issue, as it's how QuickBooks was designed. Because a deposit transaction in QuickBooks can contain multiple lines, the bank register won't show any names even if there's just one line. You can manually go to the bank register and add the name, but there's not a way to do it through the SDK. It's a two step process to even do it in QuickBooks, where you create the deposit, then go and edit it in the register.
If you need to have this information show from transaction using the SDK, then you might have to use Journal Entries instead of a Deposit transaction.
I have successfully setup the oauth authentication to access my dropbox using sharpbox. Sharpbox is an open source "front end" that handles the nuts and bolts of the process. Using it i can return file info in a particular folder in my account.
I bind the filename and a generated URI to a gridview in a VS 2010 web app. I have a hyperlink with the text set to name and the DataNavigateUrlFields to the unique URL. It works great IF there is no "+" character in the oauth_signature part of the url string. If the plus is there, it returns "{"error": "Invalid signature. Expected signature base string:"
Thanks for your consideration.
Thank you for your help, here is my code
Public Sub MakeURL()
dbOpen()
Dim myfolder As ICloudDirectoryEntry = dropBoxStorage.GetFolder("/DIR/SUBDIR/")
Filename = Filename & "_POID_" & poid & ".pdf"
pdfurl = dropBoxStorage.GetFileSystemObjectUrl(Filename, myfolder).ToString
dbClose()
pdfurl = pdfurl.Replace("+", "%2B")
Response.Redirect(pdfurl)
End Sub
OAuth 1 Signature uses Percent Encoding (See RFC 5849). The specification clearly states that a space should not be encoded to a +, instead it should be encoded with %20. Replace your + with %20.