OmniAuth Taobao OAuth2

Taobao OAuth2 Strategy for OmniAuth 1.0.

Read Taobao OAuth2 docs for more details: http://open.taobao.com/doc/detail.htm?spm=a219a.7386781.0.0.i9rfFM&id=118

Installing

Add to your Gemfile:

gem 'omniauth-taobao-oauth2'

Then bundle install.

Or install it yourself as:

$ gem install omniauth-taobao-oauth2

Usage

OmniAuth::Strategies::Taobao is simply a Rack middleware. Read the OmniAuth 1.0 docs for detailed instructions: https://github.com/intridea/omniauth.

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

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :taobao, ENV['TAOBAO_KEY'], ENV['TAOBAO_SECRET']
end

Authentication Hash

Here's an example Authentication Hash available in request.env['omniauth.auth']:

{
       "provider" => "taobao",
            "uid" => xxxxx,
           "info" => {
        "nickname" => "xxxxxxx"
    },
    "credentials" => {
                "token" => "xxxxxxxxxxxxxxxxxxxxxx",
        "refresh_token" => "xxxxxxxxxxxxxxxxxxxxxx",
           "expires_at" => xxxxxx,
              "expires" => true
    },
          "extra" => {
        "raw_info" => {
               "nick" => "xxxxxxx",
            "user_id" => xxxxxxx
        }
    }
}

PS. Built and tested on MRI Ruby 1.9.3

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request