Exact online: get a token oauth2
Hi all
I'm fighting to connect our Coldfusion (x 64) 11 oauth2 used by Exact Online Accounting s APImethods.
Every call that I always return status 400 - Bad request. No additional information is provided, nor found on their development site.
I've been in contact with their support team, but as they have no knowledge of Java/Coldfusion, they just to send me an example of call .net HTTP:
strTokenBody = "code=" & strCode strTokenBody = strTokenBody & "&client_id=" & strClientID strTokenBody = strTokenBody & "&client_secret=" & strClientsecret strTokenBody = strTokenBody & "&redirect_uri=" & strCallbackURL strTokenBody = strTokenBody & "&grant_type=authorization_code" byteArray = Encoding.ASCII.GetBytes(strTokenBody) uri = strBaseURL & "/api/oauth2/token" Dim req As WebRequest = WebRequest.Create(uri) req.ContentType = "application/x-www-form-urlencoded" req.Method = "POST" req.ContentLength = byteArray.Length Dim stream As Stream = req.GetRequestStream() stream.Write(byteArray, 0, byteArray.Length) stream.Close()
The credentials, I do check and work with the sample code above, according to the employee of the assistance service. Then, he stressed that the HTTP body must be an array of bytes to an ASCII encoded string, which is a count of all parameters to pass.
I tried following approaches:
-J' checked on the PHP code example that the Exact has put in place, but I can't determine the setting that escapes me.
-changed the URL of the call to a local model to drop the demand (and headers) and I see that all the settings are there and that it appears correctly.
Can someone point me in the right direction on how to proceed in this?
Thanks for reading so far,
Regards Bert.
CFC, I did:
<cfcomponent> <cfscript> // define all paths used for interfacing VARIABLES.Exact = { URL = { main = "https://start.exactonline.be/api", // main access URL authenticate = "/oauth2/auth", // for optaining an access code token = "/oauth2/token", // to get / refresh an access token user = "/v1/current/Me" // get current user data }, access = { client = { name = "MyName", // from API access token id = "pre-generated API Id ", // from API access token secret = "pre-generated API secret" // from API access token }, redirectURI = "My Site URL", forceLogin = 0, code = "Optained code through manual login form" }, settings = { grant_authorization_code = "authorization_code", grant_refresh_token = "refresh_token", response_type_code = "code" } }; // define the access token used in all API calls. Must be optained before starting any work. THIS.token = { access = "", // access key used for the session type = "", // type of token expiresIn = 600, // seconds the token will be life, default = 10 min refresh = "" // handle used to refresh current }; </cfscript> <cffunction name="CreateASCIIByteArray" access="private" returntype="Any" output="false" hint="Converts a ColdFusion string to an ASCII Java byte array."> <cfargument name="str" type="string" required="true" hint="The string to get the byte array for."> <cfscript> return ToBinary( toBase64( ARGUMENTS.str ) ); </cfscript> </cffunction> <cffunction name="GetToken" access="public" returntype="any" output="false" hint=""> <cfscript> LOCAL.URL = VARIABLES.Exact.URL.Main & VARIABLES.Exact.URL.token; LOCAL.result = DoHTTPRequest( method = "post", url = LOCAL.URL, params = [ NewRequestParam(type="formField", name="client_id", value=VARIABLES.Exact.access.client.id), NewRequestParam(type="formField", name="client_secret", value=VARIABLES.Exact.access.client.secret), NewRequestParam(type="formField", name="redirect_uri", value=VARIABLES.Exact.access.redirectURI), NewRequestParam(type="formField", name="grant_type", value=VARIABLES.Exact.settings.grant_authorization_code), NewRequestParam(type="formField", name="code", value=VARIABLES.Exact.access.code) ] ); return LOCAL.result; </cfscript> </cffunction> <cffunction name="NewRequestParam" access="private" returntype="struct" output="false" hint="Creates a new request parameter"> <cfargument name="type" type="string" required="false" default="URL" hint="[header,CGI,body,XML,file,URL,formField,cookie]"> <cfargument name="name" type="string" required="true" hint="Name of the parameter"> <cfargument name="value" type="string" required="false" default="" hint="value for the paramter"> <cfreturn ARGUMENTS> </cffunction> <cffunction name="DoHTTPRequest" access="private" returntype="Any" output="true" description="performs an HTTP request and returns the result as a structure."> <cfargument name="method" type="string" required="false" default="get" hint="[get,post,delete]"> <cfargument name="url" type="string" required="true" hint="the complete URL to call"> <cfargument name="params" type="array" required="false" default="#ArrayNew(1)#" hint="parameter list to send along the request, created with NewRequestParam()."> <cfscript> // launch the http request LOCAL.httpRequest = new http( method = uCase(ARGUMENTS.method), charset = "utf-8", url = ARGUMENTS.url, compression = "none" ); if (ARGUMENTS.method == "post") { LOCAL.httpRequest.setMultipartType("form-data"); } // add params to request body LOCAL.body = []; LOCAL.paramCount = arrayLen(ARGUMENTS.params); for (LOCAL.index = 1; LOCAL.index <= LOCAL.paramCount; LOCAL.index++) { LOCAL.currentParam = ARGUMENTS.params[LOCAL.index]; if (LOCAL.currentParam.type == "header") { LOCAL.httpRequest.addParam( argumentCollection = LOCAL.currentParam ); } else { arrayAppend( LOCAL.body, LOCAL.currentParam.name & "=" & LOCAL.currentParam.value ); } } // end-for LOCAL.httpRequest.addParam( type = "body", value = CreateASCIIByteArray( str = arrayToList(LOCAL.body, "&") ) ); // fire request try { LOCAL.http = LOCAL.httpRequest.send().getPrefix(); // return serialized filecontent when able. if ( isJSON(LOCAL.http.FileContent) ) { LOCAL.return = deserializeJSON(LOCAL.http.Filecontent); LOCAL.return.statusCode = listFirst(LOCAL.http.statusCode," "); // status code is returned as "200 OK" instead of the number. } else { LOCAL.return = { statusCode = 500, message = LOCAL.http.Filecontent, request = LOCAL.httpRequest, result = LOCAL.http }; } // end-if } catch (any except) { LOCAL.return = { statusCode = 500, message = except.type & " : " & except.message, URL = ARGUMENTS.url, params = ARGUMENTS.params, fullExcept = except }; } // end-catch return LOCAL.return; </cfscript> </cffunction> </cfcomponent>
I finally managed to make it work, but it seems that exact online needs a few valid userAgent sent along! CF sends the value 'Coldfusion' as the default user agent string.
Right now I put in userAgent = "Mozilla/5.0" in my cfhttp, I got my symbolic discount.
To be on the safe side, I also added compression = 'none' setting to my cfhttp.
Best regards, Bert.
Tags: ColdFusion
Similar Questions
-
Original title: opening of the session of market age of Empires product key online
When I try to get a product key for Age of Empires Online, occurs an error 80154002 accusing an account issue that does not exist. And when I try to solve the problem, the program will stop responding. What should I do?You use the same login that you initially used when signing on Xbox.com? WLID even or two different?
Move, delete or recover your Xbox LIVE gamertag
http://support.Xbox.com/en-us/pages/Xbox-Live/how-to/Xbox-Live-account-management/gamer-profile.aspx
-
Also exact table Get and set row height
Hi Chaps,
I am after a script to read a comprehensive document that contains tables with different heights of line.
I need the script to get the height of each row and then update the cell Options > rows and columns > line = exactly & Maximum height = {row.height} for each line
Any guidance or help would be great!
Thank you very much
SamuelYes,
Mini height adjustment & max is good enough for freezing cells, it seems.
If the value:
row.autoGrow = true;
-
I try to install my Windows updates on my Windows XP machine. I go to the windows update site, click on "Express" method to install. And get the error message "site has encountered a problem and cannot display the page, you are you are trying to view. I rebooted several times and tried several times, always with the same result. Also, there is an error number in the dialog box. The error number is 0 x 80070424
Any suggestions?
You can also check this thread http://answers.microsoft.com/en-us/windows/forum/windows_other-windows_update/windows-update-error-0x80070424/6511a332-7de3-4f10-b823-49b6dae86b9c for so the troubleshooting steps possible.
-
I'm getting invalid token on line 21 and 23.
And I don't know which characters are not valid!
http://podcast.l2today.com/L2-podcast.XML
This link might give you a better idea of what is happening. Help, Roger! I know that you are there.
https://validator.w3.org/feed/check.cgi?URL=http%3A%2f%2Fpodcast.l2today.com%2Fl 2 - podcast.xml
-
When exactly PersistentStore get deleted?
I've seen this issue mentioned in http://supportforums.blackberry.com/t5/Java-Development/Best-Practices-for-Storing-Application-Confi...
but I would ask explicitly. So I'm not actually remove objects from PersistentStore, when and how are they destroyed as the application is removed or changed? In particular, I am interested in a few aspects:
1. the impact of my object is a native class as Hashtable vs my own derived class 'MyHashtable' which is not referenced elsewhere.
2 deleting an application compared to upgrade an application in place.
Any help is appreciated.
Thank you
Jim
If you store a clean class (that implements persistable) the store is deleted when the application is removed.
If you store a generic class, what it is not.
-
How can I get my printer back online
My printer is ready to print, but it says offline and can't seem to get it online
Hi Helen,
1. don't you make changes to the computer before the show?
2. when exactly you get the message saying printer is off line?
3. What is the brand and model of the printer number?
Try to right click on the printer and click go online and see if that solves the problem.
If the steps above did not help, then follow the steps described in the links below and check if that helps.
http://support.Microsoft.com/kb/308028
http://Windows.Microsoft.com/en-us/Windows/help/printer-problems-in-Windows
Hope it will be useful.
-
Associate given carrier OAuth2 APEX user token when performing a query
Hello community,
We are developing a web application that relies heavily on the RESTful data queries.
To do this, we have different users of the APEX (they are each a separate application user) who partner with some projects.
We conduct approval via features integrated OAuth2, in fact through the flow of code-Protocol to issue a token to the bearer.
Now, by making the actual REST query, we cannot use APEX_UTEL_CURRENT_USER_ID or something like that for us return the desired information
.
Is how to get the user associated with the given token?
Our idea was to get the token in the request header and search for it in a "Token" Table, but unfortunately, we have no idea where (and if) the chips are stored.
How can we not only generally restrict or grant access to RESTful web services, but provide a result that contains only the data of the user has access to?
Thanks in advance!
We have found the solution, it's actually pretty simple:
Just use the property: ": current_user.
-
Could not get the debugging token
What is the problem? I tried to generate a new token to https://www.blackberry.com/SignedKeys/codesigning.html and it's always the same problem...
Get device PIN
Device PIN: 2xxxxeea
Request Debug token
Error: Server returned HTTP response code: 403 for URL: http://www.rim.net/Websigner/servlet/PBDT-WaterlooI got it working at home, finally... I think I can get the token does not work on some servers transparent http proxy/firewall...
-
Hi guys,.
I don't have much experience with echo adobe sign api, I want to let my users send their agreements of my site and I do not redirect to Portal sign echo when sending documents.
Is there a way I can get access to the api token without redirection to the Portal sign echo?
Note: I noticed in the api v2 here REST API - documents electronic signature software - Adobe Document Cloud, allowed to get the token via login and password sent in the http request, does v5 api also supports something similar to that?
Thank you!
Hello Mary,.
According to the mentioned workflow, it is not possible to achieve this goal without going through the platform of E-Sign using calls to API or OAuth.
Kind regards
-Usman
-
How to get into Backgammon after the message "General error"?
I'm registered, I chose the version computer game, standard, game, then display 'General error', 'try to reload. No way to reload that AFAIK. How can I make it work. I turned off blocking.
Hi CarolCaseZO,1. When you say Backgammon are you referring to an online game?2. when exactly you get this error message?3. were there any changes made to the computer before the question?4. what browser do you use?5. If you use Internet Explore version of Internet explore you use?Find out what version of Internet Explorer you are usingCheck out the link mentioned below, if you are using Internet explorer.The problems of games online using Internet ExplorerNote: Reset the Internet Explorer settings can reset security settings or privacy settings that you have added to the list of Trusted Sites. Reset the Internet Explorer settings can also reset parental control settings. We recommend that you note these sites before you use the reset Internet Explorer settings.For reference:How to optimize Internet Explorer
http://support.Microsoft.com/kb/936213/no
Note: Reset the Internet Explorer settings can reset security settings or privacy settings that you have added to the list of Trusted Sites. Reset the Internet Explorer settings can also reset parental control settings. We recommend that you note these sites before you use the reset Internet Explorer settings.Method 2:If the problem persists, I suggest that you post your request in the community of MSN games, for further assistance:
http://zone.MSN.com/en/General/article/community.htmPost a screenshot of this question on this forum so that we can understand the question in a better way.How i: post a screen shot on this forum?Hope this information helps. -
I've already updated and download the patches to remove HP with Windows XP, I always get error messages about SQL writer indicating the library has been corrupted and reinsert it doesn't tell me which library or where it is located and all microsoft help doctor's visits did not solve the problem nor has take it to a computer fix place0 which was a waste of $100,00 ~!
Discs that I got for my computer does not appear in the shot and I have no way to fix my computer that I use for home based work.
Could someone finally help me before I throw this computer out the window? It was more expensive that it was supposed to for be to work online - incidentally does not have Norton antivirus to prevent viruses!
Hi Jen98051,
1. when exactly you get the error message?
2. What is the exact error message?We recommend that you restore the computer and check if the problem persists.
see How to restore Windows XP to a previous state .
b. Once you restore the computer to an earlier time, restart the computer and check the difference.If nothing works, then please provide us with more details on the issue, so that we can help you further.
Visit our Microsoft answers feedback Forum and let us know what you think.
-
Now I get a message "you have just disconnected a device to the audio input jack" quickly followed a message that 'you have just plugged a device in the audio." He then takes the messages. This translates to stop the music. I checked all the connections.
Hello
1. this happens when you plug in the headphones?
2. this happens to you while streaming music online?
3. when exactly you get this message?
Please follow the steps mentioned below.
Method 1:
Follow the steps mentioned below.
a. click the Start button.
b. in the Start Search , type Device Manager and press ENTER.
(c) in the Device Manager dialog box, click the Action menu, and then click find the hardware changes.
Method 2:
Please run the troubleshooter mentioned in the article below.
http://Windows.Microsoft.com/en-us/Windows-Vista/tips-for-fixing-common-sound-problems
See also the below mentioned link.
-
I get a Microsoft Search Protocol Host has stopped working the alert box. How to solve this? It gives me the option to 'Search online (recommended)', but when I click on it nothing happens. Tried to restart and used Malware Bytes and my security suite Norton to seek something malicious, without success. Any suggestions?
Hello
1. have you made changes on the computer before this problem?
2. when exactly you get this error?
I suggest you try to reset to a new start Indexing Options by removing and then rebuild the index and check if it helps.
Your search index requires virtually no maintenance. However, if the index looking for files that you know problems must be in a location indexed; You may have to re-create the index.To rebuild the index:
a. open indexing and Search Options by clicking the Start button, click on the Control Panel, clicking system and Maintenance, and then clicking Indexing Options.
b. click Advanced Options, click the index settings tab and then click on rebuild. If you are prompted for an administrator password or a confirmation, type the password or provide confirmation.
See the link below for more details:
Improve Windows searches using the index: frequently asked questions
http://Windows.Microsoft.com/en-us/Windows-Vista/improve-Windows-searches-using-the-index-frequently-asked-questionsFor more information, see the following Microsoft articles:
The problems with the search
http://Windows.Microsoft.com/en-us/Windows-Vista/troubleshoot-problems-with-searchingYou can also check out the msdn below link for a similar problem and see if that solves the problem:
Hope the information is useful.
-
I just started getting this error message:
RundDLL
"There is a problem starting
c:\Users\username\AppData\Local\Temp\stppvxe\starvfn\wow.dll ".
the specified module could not be found
The computer seems to work ok and selecting ok will leave the error, and allow the user to continue. Any suggestions on what this could be and how get rid of?
Thank you
Danielle
Original title: starvfn\wow.dll
Hello
Thanks for posting in the Microsoft Community.
The description of the issue, you get wow.dll at startup. I'll be happy to help you on this question.
1. don't you make changes to the computer before the show?
2. when exactly you get the error message?This problem can occur if the waw.dll file is corrupted.
Method 1: I would say that you run SFC scan. Scan SFC will be scans all protected system files and replaces incorrect versions with appropriate Microsoft versions.
How to use the System File Checker tool to fix the system files missing or corrupted on Windows Vista or Windows 7
http://support.Microsoft.com/kb/929833Method 2: I suggest you perform the clean boot and remove the program that is causing the problem.
How to perform a clean boot for a problem in Windows Vista, Windows 7 or Windows 8
http://support.Microsoft.com/kb/929135Note: Follow how to reset the computer to start as usual after a repair by article KB929135 clean boot to reset the computer in normal mode.
Method 3: This problem can also occur if the computer is affected by the virus.
Microsoft safety scanner
http://www.Microsoft.com/security/scanner/en-us/default.aspxNote:
when you perform online virus scanyou will lose some data which are affected by the virus. Microsoft is not responsible for the loss of this data.Hope this information is helpful and let us know if you need help with Windows in the future. We will be happy to help.
Maybe you are looking for
-
I'm using an iphone 5 s. Update ios 10.0.1. I can't cut my shutter sound camera even if I toggle the silence in silent mode button. The sound is so loud and noisy. Help, please
-
Why my layout is all wrong until I connect to my site?
I just upgraded from v3 to v4 of Firefox. Myself and other members now us problems with the layout of the site. If you use Firefox 4 and visit http://www.vwaudiforum.co.uk/forum/forum.php , you should see the layout all wrong... If you look in other
-
I can print apps but I am wireless and can't print from the web wat I do?
I'm not sure why I can print apps and I can't print from the web, but I'm not sure what to do ideas? my printer is hp photosmart d110 all in one series
-
I created a movie in movie maker xp - how to access the movie with Windows movie maker 7?
I want to access the movie file and continue working on it. Movie Maker (MM) W7 does not open my movie file 1-1/2 years. I have a new PC with W7 - I also tried to open MM in virtual XP mode. No luck. There is an MM program in XP mode, but it does no
-
HP Envy 5530th: unable to pint to HP 5530e of Roxio NXT Application
I can't print wirelessly or via a USB cable to my printer HP 5530th, Envy of my application Roxio NXT. In the "what to see Print window", I see the icon document, but there is not assocated with it file name. After a few seconds, the file icon disapp