Giter Site home page Giter Site logo

sethherr / grape-doorkeeper Goto Github PK

View Code? Open in Web Editor NEW
79.0 5.0 24.0 216 KB

Get to API building quickly

Home Page: https://grape-doorkeeper.herokuapp.com

License: MIT License

Ruby 68.29% JavaScript 0.27% CoffeeScript 3.07% CSS 5.16% HTML 23.08% Shell 0.12%
ruby rails-application doorkeeper omniauth swagger grape swagger-ui

grape-doorkeeper's Introduction

Grape-Doorkeeper

Create an awesome versioned API, secured with OAuth2 and automatically documented.

This is a basic Rails 5 application with Doorkeeper, Grape & Swagger for getting to API building quickly.

You can view the live app and the Swagger-ui documentation.

This app is ready to deploy to Heroku Deploy

Set up

This app includes omniauth-bike-index. For Bike Index login to work, create a Bike Index app at BikeIndex.org/oauth/applications/new and add the values from BIKEINDEX_APP_ID and BIKEINDEX_APP_SECRET to the .env file.

Bike Index uses a similar grape, Swagger, doorkeeper setup—this is an example of creating an OmniAuth strategy for doorkeeper.

Adding to an existing application

View how to on the wiki.

Notes

Grape is mounted in app/controllers/api, as described in the excellent Introduction to building APIs with Grape by Monterail, and part 2 of the series.

There are are other posts in the series which are worth reading, particularly OAuth Implicit Grant with Grape, Doorkeeper and AngularJS.

There is also a Railscast on doorkeeper.

Important things in the Gemfile:

Also important, but maybe not as necessary to know about:


If you want to change the name of the app, swap out:

Testing

Rspec and guard - run bundle exec guard to watch your spec files for changes and rerun tests for those files.

There is a spec for the api/v1/me API route and for the swagger docs to help get you started.

grape-doorkeeper's People

Contributors

sethherr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

grape-doorkeeper's Issues

authorise fail when request access token for particular scope

steps to reproduce

  1. create a application
  2. authrise without scope
  3. go to document page
  4. delete the access token
  5. go back to document page
  6. choose a scope like "write_user" to request a new token
  7. click the auth link, it fails with the error showing on the page
The requested scope is invalid, unknown, or malformed.

proposed fix:
in config file "doorkeeper.rb", change the line from

optional_scopes OAUTH_SCOPES

to

optional_scopes *OAUTH_SCOPES

(unwrap the params)

login_url redirection issue when auth a application

08:08:44 log.1        | NameError (undefined local variable or method `login_url' for #<Doorkeeper::AuthorizationsController:0x007ff27b0e2868>):
08:08:44 log.1        |   config/initializers/doorkeeper.rb:12:in `block (2 levels) in <top (required)>'

the issue is in the file of "config/initializers/doorkeeper.rb:12"
should change from

current_user || redirect_to(login_url)

to

current_user || redirect_to(new_user_session_url)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.