doorkeeper
Search…
Grape

Grape integration

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.
1
require 'doorkeeper/grape/helpers'
2
3
module API
4
module V1
5
class Users < Grape::API
6
helpers Doorkeeper::Grape::Helpers
7
8
before do
9
doorkeeper_authorize!
10
end
11
12
# For old versions of Grape:
13
# route_setting :scopes, ['user:email']
14
#
15
get :me, scopes: [:user, :read] do
16
current_user.to_json
17
end
18
19
# ...
20
end
21
end
22
end
Copied!

Auto-documented API

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).
  • swagger ui rails The swagger-ui_rails gem provides asset pipeline assets for swagger-ui - beautiful, interactive documentation.
  • wine_bouncer The wine_bouncer gem protects grape with Doorkeeper, documents it in swagger, and permits scoping-based protection.
Last modified 1yr ago