Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Added description how to Protect your API with OAuth when using Grape
after PR 567.

#567 (comment)
  • Loading branch information
RinkeRiezebos authored and tute committed Mar 25, 2015
1 parent ab8cf72 commit 2258af3
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
[![Gem Version](https://badge.fury.io/rb/doorkeeper.svg)](https://rubygems.org/gems/doorkeeper)

Doorkeeper is a gem that makes it easy to introduce OAuth 2 provider
functionality to your Rails application. As of [PR 567] it plays nicely with
Grape framework.
functionality to your Rails or Grape application.

[PR 567]: https://github.com/doorkeeper-gem/doorkeeper/pull/567

Expand All @@ -30,6 +29,7 @@ https://github.com/doorkeeper-gem/doorkeeper/releases.
- [Routes](#routes)
- [Authenticating](#authenticating)
- [Protecting resources with OAuth (a.k.a your API endpoint)](#protecting-resources-with-oauth-aka-your-api-endpoint)
- [Protect your API with OAuth when using Grape](#protect-your-api-with-oauth-when-using-grape)
- [Route Constraints and other integrations](#route-constraints-and-other-integrations)
- [Access Token Scopes](#access-token-scopes)
- [Authenticated resource owner](#authenticated-resource-owner)
Expand Down Expand Up @@ -174,6 +174,36 @@ end
You can pass any option `before_action` accepts, such as `if`, `only`,
`except`, and others.

### Protect your API with OAuth when using Grape

As of [PR 567] doorkeeper has helpers for Grape. One of them is
`doorkeeper_authorize!` and can be used in a similar way as an example above.
Note that you have to use `require 'doorkeeper/grape/helpers'` and
`helpers Doorkeeper::Grape::Helpers`.

For more information about integration with Grape see the [Wiki].

[PR 567]: https://github.com/doorkeeper-gem/doorkeeper/pull/567
[Wiki]: https://github.com/doorkeeper-gem/doorkeeper/wiki/Grape-Integration

``` ruby
require 'doorkeeper/grape/helpers'

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

before do
doorkeeper_authorize!
end

# ...
end
end
end
```


### Route Constraints and other integrations

Expand Down

0 comments on commit 2258af3

Please sign in to comment.