jinshuju / omniauth-jinshuju

Official support for OmniAuth OAuth 2 Ruby client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OmniAuth::Strategies::Jinshuju

OAuth2 Strategy for Jinshuju

Installation

Add this line to your application's Gemfile:

gem 'omniauth-jinshuju'

Or, if you want to use the github source:

gem 'omniauth-jinshuju', git: 'git@github.com: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"=>"user@email.com",
  },
  "extra"=> {
    "raw_info"=> {
      "type"=>"user",
      "id"=>"123456",
      "name"=>"xiaojin",
      "login"=>"user@email.com"
    }
  }
}

Contributing

Bug reports and pull requests are welcome. This project is intended to be a safe, welcoming space for collaboration.

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes along with test cases (git commit -am 'Add some feature')
  4. If possible squash your commits to one commit if they all belong to same feature.
  5. Push to the branch (git push origin my-new-feature)
  6. Create new Pull Request.

License

The gem is available as open source under the terms of the MIT License.

About

Official support for OmniAuth OAuth 2 Ruby client

License:MIT License


Languages

Language:Ruby 100.0%