Chinese Social network (weibo/qq/weixin currently) authentication with mongoid.
Add this line to your application's Gemfile:
gem 'xoauth', :require => 'oauth'
And then execute:
$ bundle
Or install it yourself as:
$ gem install xoauth
class User
include Mongoid::Document
include Mongoid::Xoauth
xoauth weibo: {'appid'=> '1112', 'secret'=> '123dffd'}
end
Then we can use the following methods:
# get the found user or nil
User.find_by_oauth_uid(uid, Oauth::Weibo)
# authorize url
Oauth::Weibo.authorize_url
# detail of code: {access_token, uid, created_at, expires_in}
# can be used to initialize Oauth::Weibo
Oauth::Weibo.detail_of_code(code)
# fetch the detail infomation of the oauth client
Oauth::Weibo#fetch_info!
- Fork it ( https://github.com/Slacken/xoauth/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request