Testing an OAuth Provider in your Rails App

16 March 2010

Recently I received a request from another B2B SaaS vendor to integrate with Catch the Best, so their users could pull their data from Catch the Best into this app. This is a classic use-case for OAuth, so I dove in to learning how to make my Rails app an OAuth provider. Well, thanks to the OAuth gem and the OAuth Rails plugin, it only took an hour or two to do.

However, since it took a little longer than it should have to do some testing of the app from the console, I thought I'd post this code in case it proves helpful to someone else working on this. My goal was to manually verify that the access control (the before filter) was working properly, so I could email the details on the OAuth endpoint to this other vendor and be reasonably sure it would work well for them. Here's the code:

Read the rest of this entry »



Why Won't FB.Connect.logoutAndRedirect work?

12 March 2010

I was banging my head against a Facebook Connect problem with one of my clients' Rails apps recently, and I thought I'd share a useful tidbit I gleaned from the experience, in case it can spare someone else the headache I had.

This app originally supported just plain-old users who created an account at the site with a username and password. Then the client requested that I add Facebook Connect as an authentication option. Using the facebooker gem, most of the work was straightforward. If a user chooses the Facebook Connect option when signing up or logging in, a User record is created and a FacebookUser record is associated with that User. The real problem came with trying to log out a Facebook Connect user.

Read the rest of this entry »