I'm working with some old code and using ActiveResource for a very basic Twitter integration. I'd like to touch the app code as little as possible and just bring OAuth in while still using ActiveResource.
Unfortunately I'm finding no easy way to do this. I did run into the oauth-active-resource gem, but it's not exactly documented and it appears to be designed for creating full-on API wrapper libraries. As you can imagine, I'd like to avoid creating a whole Twitter ActiveResource API wrapper for this one legacy change.
Any success stories out there? In my instance, it might be quicker to just leave ActiveResource rather than get this working. I'm happy to be proven wrong!
I had the same problem and built this simple gem to handle it:
https://github.com/albertopq/oauth-activeresource
You just need to use the oauth gem to retrieve the access token, and assign the final http object to your model. It will use that object instead the ActiveResource::Connection one.
Hope it helps.
I just did this with omniauth and it was surprisingly easy. This screencast and a subsequent one walks you through it. All I needed was an initializer, a controller with login/logout actions and some attributes on my user model to store the Twitter id and screen name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With