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
Add to your Gemfile
:
gem 'omniauth_qiita'
Then bundle install
.
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
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
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.
Actively tested with the following Ruby versions:
- MRI 2.1.0
- MRI 2.0.0
- MRI 1.9.3
- JRuby
- Rubinius
- 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
This software is released under the MIT License, see LICENSE.txt.