开发者

What's the easiest way to use OAuth with ActiveResource?

I'm working with some old code and us开发者_运维百科ing 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜