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
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request