-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
ActionController::Metal with doorkeeper
felipeelias edited this page Jul 15, 2012
·
5 revisions
version +0.4.1
If you're using ActionController::Metal
for your API and you want to protect it with doorkeeper OAuth, you just need to include a few modules:
class MetalController < ActionController::Metal
include AbstractController::Callbacks
include ActionController::Head
include Doorkeeper::Helpers::Filter
doorkeeper_for :all
def index
self.response_body = { :ok => true }.to_json
end
end
This is the bare minimum to get either an :unauthorized
response (that's why the Head module was included) or a authorized response with the response body.
Since doorkeeper uses a before filter, you need to include the AbstractController::Callbacks
module.
If you use rocket pants gem, you need to include these modules:
class MetalController < RocketPants::Base
include ActionController::Head
include Doorkeeper::Helpers::Filter
version 1
doorkeeper_for :all
end
Check out the related question in stack overflow