Sha256: 494b55cecb5c54adc04779df4b339ce5054cd96b58490f966a431a5898a6b919

Contents?: true

Size: 1.22 KB

Versions: 3

Compression:

Stored size: 1.22 KB

Contents

# Hensin Belt on Grape API

Hensin Belt is a Grape middleware to connect your API resources with your API authenticator.


## Installation

Add this line to your application's Gemfile:

```ruby
gem 'henshin-belt'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install henshin-belt

## Usage

### Install generator

On your first install, run this generator :

```ruby
rails g henshin_belt:install
```

### Usage with Grape

You will need to use the middleware in your main API :

```ruby
# use middleware
use ::HensinBelt::Oauth2
```

You could also use the helpers :

```ruby
# use helpers
helpers ::HensinBelt::Helpers
```

### Protecting your endpoint

In your endpoint you need to define which protected endpoint by adding this DSL :

1.  `oauth2`
2.  `oauth2(:email)`

Example :

```ruby
desc "Your protected endpoint"
oauth2 
get :protected do
    # your code goes here
end
```

```ruby
desc "Your protected endpoint with defined scope"
oauth2(:email)
get :protected do
    # your code goes here
end
```

## Nice feature

From your protected endpoint you could get :

1. `resource_token` => Your access token
2. `resource_credential` => Full credentials
3. `resource_owner` => Current Object
4. `me` => Current Object

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
henshin-belt-0.0.3 README.md
henshin-belt-0.0.2 README.md
henshin-belt-0.0.1 README.md