0.0
The project is in a healthy, maintained state
Hensin Belt is a Grape middleware to connect your API resources with your API authenticator.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.5.18
~> 13.2.1
~> 3.13.0

Runtime

~> 2.1.3
 Project Readme

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:

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 :

rails g henshin_belt:install

Usage with Grape

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

# use middleware
use ::HensinBelt::Oauth2

You could also use the helpers :

# 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 :

desc "Your protected endpoint"
oauth2 
get :protected do
    # your code goes here
end
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