No commit activity in last 3 years
No release in over 3 years
OmniAuth strategy for PrestoDoctor
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.6
~> 2.7
~> 0.10
~> 1.20

Runtime

 Project Readme

OmniAuth PrestoDoctor Strategy

OmniAuth 2 strategy for PrestoDoctor

For more details, read the PrestoDoctor API Reference

Installation

Add to your Gemfile:

gem 'omniauth-prestodoctor'

then bundle install

Usage & Configuration

Here's an example, adding the middleware to a Rails app in config/initializers/omniauth.rb:

You can configure permissions/scope (as a space separated string), which you pass in to the provider method after your PRESTO_APP_ID and PRESTO_SECRET:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :presto_doctor, ENV['PRESTO_APP_ID'], ENV['PRESTO_SECRET'], scope: 'user_info recommendation photo_id'
end

Available scopes are:

  • user_info
  • recommendation
  • photo_id

If you don't include any scope it will default to only user_info.

NOTE: While developing your application, if you change the scope in the initializer you will need to restart your app server.

You can now access the OmniAuth PrestoDoctor OAuth2 URL: /auth/prestodoctor

Usage with Devise

In your app/initializers/devise.rb, in the omniauth section, add a line using similar syntax and configuration:

config.omniauth :presto_doctor, ENV['PRESTO_APP_ID'], ENV['PRESTO_SECRET'], scope: 'user_info recommendation photo_id'

Add to your User model

For a user to be able to log in via PrestoDoctor, you will need to set on your User model:

devise :omniauthable, :omniauth_providers => [:prestodoctor]

Including in Views

You will now be able to link to the PrestoDoctor authorization path, like so:

<%= link_to user_omniauth_authorize_path(:prestodoctor) do %>
  <%= image_tag 'prestodoctor-login.png' %>
<% end %>

Callbacks

You will need to set up a callback path that we can call with the generated token

You can see an example of this here: https://github.com/PrestoDoctor/prestodoctor-oauth

(look at app/controllers/users/omniauth/callbacks_controller.rb and it's related entry in routes.rb)

Accessible data

Take a look at this screenshot for a sample of data that you can retrieve:

  • user_info scope data is inside of the info hash
  • recommendation and photo_id are contained inside of the extra hash