views:

14

answers:

1

I am working on integrating the TripIt API into a project of mine. I'm new to OAuth so I'm learning this as I go. The following controller seems to be working. However, I want to make sure I'm not leaving any glaring security holes or just being stupid.

What do you guys/gals think?

If anyone had a better example, I would certainly study it as well.

Thanks for any pointers or suggestions.

http://gist.github.com/648227

A: 

Some tips:

  • Don't require libs in methods; Add them to the top of the file, or include them in your config/environment.rb. That makes it easier to check what you include/require in your project.
  • Add comments with how each methods is called and what it's supposed to do.
  • You might want to consider (although not necessary) to move the actual 'oauth logic' to a special model, but the code relatively short, so it's okay in this case.

Otherwise this controller looks pretty good. Good use of before_filters and private methods.

Ariejan
At a later stage you may want to store your API info in another place than your controller. Using a gem like Settingslogic can make your life very easy.
Ariejan
Thanks for the suggestions. I have cleaned it up a little. Still need to add better comments. I normally do. :-) Here is the new version: http://gist.github.com/649915
cbmeeks