OmniAuth Yhd OAuth2
Yhd OAuth2 Strategy for OmniAuth 1.0.
Read Yhd OAuth2 docs for more details: http://open.yhd.com/opendoc.do
Installing
Add to your Gemfile
:
gem 'omniauth-yhd-oauth2'
Then bundle install
.
Or install it yourself as:
$ gem install omniauth-yhd-oauth2
Usage
OmniAuth::Strategies::Yhd
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 :yhd, ENV['YHD_KEY'], ENV['YHD_SECRET']
end
Authentication Hash
Here's an example Authentication Hash available in request.env['omniauth.auth']
:
{
"provider" => "yhd",
"uid" => xxxxx,
"info" => {
"nickname" => "xxxxx旗舰店"
},
"credentials" => {
"token" => "f841875xxxxxxxxx81509d",
"expires_at" => xxxxxxxxx,
"expires" => true
},
"extra" => {
"raw_info" => {
"storeId" => xxxxxxxxx,
"storeName" => "xxxxxxxx旗舰店",
"storeAddress" => "http://shop.yhd.com/html/xxxxx",
"storeOpenTime" => "2xxx-xx-03 17:xx:13",
"storeCategoryCode" => xxx,
"storeNickName" => ""
}
}
}
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