Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
30 lines (21 sloc) 932 Bytes

Grape

Starting from version 2.2 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.

For more information about integration with Grape see the Wiki.

require 'doorkeeper/grape/helpers'

module API
  module V1
    class Users < Grape::API
      helpers Doorkeeper::Grape::Helpers

      before do
        doorkeeper_authorize!
      end

      # route_setting :scopes, ['user:email'] - for old versions of Grape
      get :emails, scopes: [:user, :write] do
        [{'email' => current_user.email}]
      end

      # ...
    end
  end
end
You can’t perform that action at this time.