Add facebook grant_type to devise_oauth2_providable
Ruby JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
tests
.gitignore
.rspec
Gemfile
LICENSE.txt
README.md
Rakefile
oauth2_facebook_grantable.gemspec

README.md

oauth2_facebook_grantable

Adds a grant_type "facebook" to the existing installation of devise_oauth2_providable

Features

  • Allows to provide facebook_id and facebook_access_token to authenticate against an OAuth2 API made with devise_oauth2_providable

Requirements

Installation

Install gem

# Gemfile
gem 'oauth2_facebook_grantable'

Migrate database

It essentially adds a facebook_identifier column to the User model. It's required so the plugin can find a user based on its facebook_id

$ rails g oauth2_facebook_grantable:install
$ rake db:migrate

Configure User model to support Facebook authentication

Add :oauth2_facebook_grantable to your devise declaration as seen bellow.

class User
  devise :oauth2_providable,
    :oauth2_password_grantable,
    :oauth2_refresh_token_grantable,
    :oauth2_facebook_grantable
end

Using with Facebook grant_type on the client-side

To authentitcate against to the API using Facebook credentials you need to post the API with the parameter facebook_identifier and facebook_access_token as shown bellow:

post("/oauth/token",
  :format => :json,
  :facebook_identifier => facebook_id,
  :facebook_access_token => facebook_access_token,
  :grant_type => "facebook",
  :client_secret => client_secret,
  :client_id => client_identifier)

Contributing

  • Fork the project
  • Fix the issue
  • Add unit tests
  • Submit pull request on github

License

Copyright (C) 2012 Pierre-Luc Simard See LICENSE.txt for further details.