Skip to content
felipeelias edited this page Jun 4, 2012 · 7 revisions

Version > 0.5

Doorkeeper routes accepts few customization options for generating routes in your application:

The basic generated routes are:

# routes.rb
Rails.application.routes.draw do
  use_doorkeeper
end

generates:

GET       /oauth/authorize
POST      /oauth/authorize
DELETE    /oauth/authorize
POST      /oauth/token
resources /oauth/applications

Changing controllers

You may want to change the controllers to you custom controllers with:

Rails.application.routes.draw do
  use_doorkeeper do
    # it accepts :authorizations, :tokens, :applications and :authorized_applications
    controllers :applications => 'custom_applications'
  end
end

You'll need a CustomApplicationsController class in your app/controllers. If you want to extend the default behaviour, just inherit from Doorkeeper::ApplicationsController, for example:

class CustomApplicationsController < Doorkeeper::ApplicationsController
end

Changing aliases

If can change the alias options with as:

Rails.application.routes.draw do
  use_doorkeeper do
    # it accepts :authorizations, :tokens, :applications and :authorized_applications
    as :authorizations => 'custom_auth', :tokens => 'custom_token'
  end
end

Skipping controllers

If you want to skip some routes and provide your own routes, use skip_controllers option:

Rails.application.routes.draw do
  use_doorkeeper do
    # it accepts :authorizations, :tokens, :applications and :authorized_applications
    skip_controllers :applications, :authorized_applications
  end
end

Namespacing

You can namespace doorkeeper routes just like you do in the usual rails routes:

Rails.application.routes.draw do
  scope 'space' do
    use_doorkeeper
  end
end

This will generate:

GET       /space/oauth/authorize
POST      /space/oauth/authorize
DELETE    /space/oauth/authorize
POST      /space/oauth/token
resources /space/oauth/applications

This also applies to constraints too.

Clone this wiki locally