These notes are based on master, please see tags for README pertaining to specific releases.
Qiita OAuth2 Strategy for OmniAuth.
Supports the OAuth 2.0 server-side and client-side flows. Read the Qiita docs for more details: https://qiita.com/api/v2/docs
Installing
Add to your Gemfile
:
gem 'omniauth_qiita'
Then bundle install
.
Usage
OmniAuth::Strategies::Qiita
is simply a Rack middleware. Read the OmniAuth 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 :qiita, ENV['QIITA_CLIENT_ID'], ENV['QIITA_CLIENT_SECRET']
end
Configuring
You can configure scope option, which you pass in to the provider
method via a Hash
:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :qiita, ENV['QIITA_CLIENT_ID'], ENV['QIITA_CLIENT_SECRET'],
:scope => 'read_qiita read_qiita_team write_qiita write_qiita_team'
end
Auth Hash
Here's an example Auth Hash available in request.env['omniauth.auth']
:
{
:provider => "qiita",
:uid => "tmiyamon",
:info => {
:nickname => "tmiyamon",
:name => "Takuya Miyamoto",
:location => "Tokyo, Japan",
:image => "https://....",
:description => "An awesome engineer",
:urls => {
:Facebook => "https://www.facebook.com/...",
:Github => "https://github.com/tmiyamon",
:Twitter => "https://twitter.com/..."
}
},
:credentials => {
:token => "abc...",
:expires => false
},
:extra => {
:raw_info => {
:description => "An awesome engineer",
:facebook_id => "...",
:followers_count => 5,
:followees_count => 0,
:github_login_name => "tmiyamon",
:id => "tmiyamon",
:items_count => 3,
:linkedin_id => "",
:location => "Tokyo, Japan",
:name => "Takuya Miyamoto",
:organization => "",
:profile_image_url => "https://...",
:twitter_screen_name => "...",
:website_url => "http://tmiyamon.github.io"
}
}
}
The precise information available may depend on the permissions which you request.
'urls' in info may contains 'Facebook', 'Github', 'Twitter', 'LinkedIn' and 'Website' which depends on the account information you link in Qiita.
Supported Rubies
Actively tested with the following Ruby versions:
- MRI 2.1.0
- MRI 2.0.0
- MRI 1.9.3
- JRuby
- Rubinius
Contributing
- Fork it ( https://github.com/tmiyamon/omniauth_qiita/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
License
This software is released under the MIT License, see LICENSE.txt.