OmniAuth::Strategies::Jinshuju
OAuth2 Strategy for Jinshuju
Installation
Add this line to your application's Gemfile:
gem 'omniauth-jinshuju', git: '[email protected]:jinshuju/omniauth-jinshuju.git'
And then execute:
$ bundle
Usage
You need client_id
& client_secret
.
Here's an example for adding the middleware to a Rails app in config/initializers/omniauth.rb:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :jinshuju, ENV["JINSHUJU_CLIENT_ID"], ENV["JINSHUJU_CLIENT_SECRET"]
end
Or If your are using devise add follwing in config/initializers/devise.rb
config.omniauth :jinshuju, ENV["JINSHUJU_CLIENT_ID"], ENV["JINSHUJU_CLIENT_SECRET"]
Then add the following to 'config/routes.rb' so the callback routes are defined.
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
Make sure your model is omniauthable. Generally this is "/app/models/user.rb"
Sample Auth Hash
{
"provider"=>"jinshuju",
"uid"=>"123456",
"info"=> {
"name"=>"xiaojin",
"email"=>"[email protected]",
},
"extra"=> {
"raw_info"=> {
"type"=>"user",
"id"=>"123456",
"name"=>"xiaojin",
"login"=>"[email protected]"
}
}
}
Contributing
Bug reports and pull requests are welcome. This project is intended to be a safe, welcoming space for collaboration.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes along with test cases (
git commit -am 'Add some feature'
) - If possible squash your commits to one commit if they all belong to same feature.
- Push to the branch (
git push origin my-new-feature
) - Create new Pull Request.
License
The gem is available as open source under the terms of the MIT License.