doorkeeper
  • Doorkeeper Guides
  • Ruby on Rails
    • Getting Started
    • Routes
    • Configuration
    • Scopes
    • Securing the API
    • API Mode
    • PKCE Flow
    • Polymorphic Resource Owner
  • Grape
    • Grape
  • ORMs
    • Active Record
    • MongoDB
    • Sequel
    • Couchbase
  • Internals
    • Database Design
    • Internationalization (i18n)
    • Rake
    • Testing
    • Upgrading
    • Creating extensions
  • Security
    • Token and Application Secrets
  • Configuration
    • Models
    • Scopes
    • Skip Authorization
    • Other Configurations
    • Route Constraints and other integrations
Powered by GitBook
On this page
  • Custom Access Token Generator
  • Custom controllers
  • Customizing errors
  • Other customizations

Was this helpful?

  1. Configuration

Other Configurations

PreviousSkip AuthorizationNextRoute Constraints and other integrations

Last updated 5 years ago

Was this helpful?

Custom Access Token Generator

By default a 128 bit access token will be generated. If you require a custom token, such as , specify an object that responds to .generate(options = {}) and returns a string to be used as the token.

Doorkeeper.configure do
  access_token_generator "Doorkeeper::JWT"
end

JWT token support is available with .

Custom controllers

By default Doorkeeper's main controller Doorkeeper::ApplicationController inherits from ActionController::Base. You may want to use your own controller to inherit from, to keep Doorkeeper controllers in the same context than the rest your app:

Doorkeeper.configure do
  base_controller 'ApplicationController'
end

Also you could override Doorkeeper::ApplicationMetalController that is ActionController::API by default.

Doorkeeper.configure do
  base_metal_controller 'ApplicationController'
end

Customizing errors

If you don't want to use default Doorkeeper error responses you can raise and rescue it's exceptions. All you need is to set configuration option handle_auth_errors to :raise. In this case Doorkeeper will raise Doorkeeper::Errors::TokenForbidden, Doorkeeper::Errors::TokenExpired, Doorkeeper::Errors::TokenRevoked or other exceptions that you need to care about.

Other customizations

see more on

JWT
Doorkeeper-JWT
Associate users to OAuth applications (ownership)
CORS - Cross Origin Resource Sharing
Wiki page