Skip to content

PrestoDoctor/omniauth-prestodoctor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Omniauth strategy for PrestoDoctor Login

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages