Doorkeeper provides helpers for the Grape framework >= 0.10. One of them is
doorkeeper_authorize! that can be used in a similar way as an example above to protect your API with OAuth. Note that you have to use
require 'doorkeeper/grape/helpers' and
helpers Doorkeeper::Grape::Helpers in your Grape API class.
require 'doorkeeper/grape/helpers'module APImodule V1class Users < Grape::APIhelpers Doorkeeper::Grape::Helpersbefore dodoorkeeper_authorize!end# For old versions of Grape:# route_setting :scopes, ['user:email']#get :me, scopes: [:user, :read] docurrent_user.to_jsonend# ...endendend
The sample app is a Rails 4 template with everything necessary to create an autodocumented, secured API in Grape with doorkeeper.
There is also a wiki page with details for how to add this to an existing application.
grape a REST-like API micro-framework for Ruby. Makes building APIs easier and faster.
grape swagger The grape-swagger gem provides autogenerated swagger documentation (it's magical).
wine_bouncer The wine_bouncer gem protects grape with Doorkeeper, documents it in swagger, and permits scoping-based protection.