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
  • Grape integration
  • Auto-documented API

Was this helpful?

  1. Grape

Grape

PreviousPolymorphic Resource OwnerNextActive Record

Last updated 5 years ago

Was this helpful?

Grape integration

Doorkeeper provides helpers for the >= 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.

require 'doorkeeper/grape/helpers'

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

      before do
        doorkeeper_authorize!
      end

      # For old versions of Grape:
      #   route_setting :scopes, ['user:email']
      #
      get :me, scopes: [:user, :read] do
        current_user.to_json
      end

      # ...
    end
  end
end

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 .

a REST-like API micro-framework for Ruby. Makes building APIs easier and faster.

grape swagger The gem provides autogenerated swagger documentation (it's magical).

swagger ui rails The gem provides asset pipeline assets for - beautiful, interactive documentation.

wine_bouncer The gem protects grape with Doorkeeper, documents it in swagger, and permits scoping-based protection.

Grape framework
Check out the sample app
how to add this to an existing application
grape
grape-swagger
swagger-ui_rails
swagger-ui
wine_bouncer