- Ruby 2.4
- Rails 5
- MongoDB 3.6.2
- If MongoDB is not installed already, install it using:
brew install mongodb
- Then run:
sudo mkdir -p /data/db
- Run MongoDB server:
mongod
- Goto project's directory in your terminal
- Run
bundle install
rails generate doorkeeper:install
rails generate doorkeeper:mongo_mapper:indexes
rails db:mongoid:create_indexes
rails db:seed
- Start the local server using
rails server
- Visit
http://127.0.0.1:3000/oauth/applications/new
and provide the details there and clicksubmit
. It will redirect you to next page. - Then on next page displayed, click on
Authorize
button. It will show you the Authorization code. - Now using postman (or any http client), do the post request to
http://127.0.0.1:3000/oauth/token/
providing the following parameters:client_id=APPLICATION-ID&client_secret=APPLICATION_SECRET&code=AUTHORIZATION-CODE&grant_type=authorization_code&redirect_uri=urn:ietf:wg:oauth:2.0:oob
- To see the token based authorization in action visit:
http://127.0.0.1:3000/get-book-info/?q=SEARCH-TERM&access_token=ACCESS-TOKEN-RECEIVED-IN-STEP3