ColdFusion and Basecamp's API

BasecampRecently I began working on a project that will integrate with Basecamp's API to fetch and sync data back and forth. My approach to the application was simple. I began by designing the interface, marking it up, and getting some basic jQuery interactions functional. After a few hours it was time to begin working with Basecamp's rather simple to use API.

I/O Exception: peer not authenticated

I'm a huge proponent of working smarter not harder, so I strolled over to RIAForge and after a quick search I was able to come up with Terrence Ryan's BasecampCFC. I plugged the CFC into my project, and began setting up a quick test just to make sure everything was working A-OK. Unfortunately I kept getting the following error:

Error in Underlying Web Call

Stumped by this, I checked my credentials, ensured API access was enabled, and tried a half dozen other things. After exhausting my options it was time to pop the hood on this CFC and see what was really going on. Bypassing all of the error handling, I dumped the contents of the cfhttp call and got the following error:

CFHTTP Dump

Initially I was using the Basecamp Token for my username and "x" for the password as the API's docs had instructed. Just to rule out any other options, I tried my actual Basecamp OpenID credentials, and still came up with the same error. When debugging code such as this I am big fan of extracting the code and placing it in a new fresh and clean template to avoid any other possibly related problems. I had copied a basic cfhttp call with all of the necessary header cfparams and still got the same error. I had tried everything my brain could fathom,and yet the error persisted. The kicker was when I decided to place this simple call on 3 other ColdFusion servers I have access to and for one reason or another a CF8 box allowed the cfhttp call to return the data fine, yet my local CF9 box still returned the I/O exception. I Google'd a few phrases and found a few related forum posts but no direct solutions, so it was time to turn this problem over to Twitter.

Getting to the Bottom of this Mess

Within minutes of posting my problem, James Allen chimed in with a few suggestions, and after debugging a few server settings he dropped a golden nugget in my bucket. Ray Camden had apparently just blogged about this exact issue when attempting to use Zencoder's API, yet for one reason or another I had not stumbled across the post yet. The solution can be found here.

<cfset objSecurity = createObject("java", "java.security.Security") />
<cfset storeProvider = objSecurity.getProvider("JsafeJCE") />
<cfset objSecurity.removeProvider("JsafeJCE") />

<cfhttp ... > ... </cfhttp>

<cfset objSecurity.insertProviderAt(storeProvider, 1) />

Conclusion

To try and explain this in simple terms, ColdFusion is bundled with multiple security providers, and the default one seemed to stumble when communicating with Basecamp's API (in my case). By explicitly using an alternate provider, we are able to successfully shake Basecamp's hand without getting slapped in the face with that I/O exception. The reason why the CF8 box worked was because it was a CF8 Professional box, and my CF9 local box was a Developer install which apparently functions like the Enterprise edition. This bug is apparently common in the enterprise edition thus affecting me on my local CF9 box. More information on this error can be found in Ray's blog post.

0 responses to “ColdFusion and Basecamp's API”

Leave a Reply

Leave this field empty:

Back to Top

Before you download my resume...

My Current Employment Status

I am currently happily employed and not actively seeking employment at this time. While I appreciate any and all interest in my skill-set, I am currently not available for a full-time hire. If you are interested in my skill-set and would like to hire me on a part-time basis, please contact me.

Contact Information

To avoid having my personal contact information floating freely through-out the internet, I have withheld my personal contact information from my resume. If you are interested in contacting me, please do so on my contact page.

Find Me, Follow Me, Friend Me!

Tags

Fellow Bloggers

Brought to you in part by

Epicenter Consulting - A Web Application Design and Strategy Firm