In an effort to avoid frequent re-writing of the same code, I've put my implementation of the OAuth2 flow for obtaining an access token into a reusable gem for Sinatra. The gem is called sinatra-canvas_auth and I just published v0.0.1 on rubygems. Source code and documentation are on Github.
I'm not sure how many of you out there are also using Sinatra, but if anyone happens to find use in this, I would love hear any kind of feedback on how it works, additional features, bugs, etc. Thanks for taking a look.