├── Rakefile ├── lib ├── omniauth-disqus.rb ├── omniauth-disqus │ └── version.rb └── omniauth │ └── strategies │ └── disqus.rb ├── Gemfile ├── .gitignore ├── omniauth-disqus.gemspec ├── LICENSE └── README.md /Rakefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rake 2 | require "bundler/gem_tasks" 3 | -------------------------------------------------------------------------------- /lib/omniauth-disqus.rb: -------------------------------------------------------------------------------- 1 | require "omniauth-disqus/version" 2 | require "omniauth/strategies/disqus" -------------------------------------------------------------------------------- /lib/omniauth-disqus/version.rb: -------------------------------------------------------------------------------- 1 | module Omniauth 2 | module Disqus 3 | VERSION = '1.0.2' 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in omniauth-disqus.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | .bundle 4 | .config 5 | .yardoc 6 | Gemfile.lock 7 | InstalledFiles 8 | _yardoc 9 | coverage 10 | doc/ 11 | lib/bundler/man 12 | pkg 13 | rdoc 14 | spec/reports 15 | test/tmp 16 | test/version_tmp 17 | tmp 18 | -------------------------------------------------------------------------------- /omniauth-disqus.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | require File.expand_path('../lib/omniauth-disqus/version', __FILE__) 3 | 4 | Gem::Specification.new do |gem| 5 | gem.name = 'omniauth-disqus' 6 | gem.authors = [ 'Chris Lexmond' ] 7 | gem.email = [ 'chris@chrislexmond.com' ] 8 | gem.description = 'A Disqus OAuth2 strategy for OmniAuth' 9 | gem.summary = 'A Disqus OAuth2 strategy for OmniAuth' 10 | gem.homepage = 'https://rubygems.org/gems/omniauth-disqus' 11 | gem.license = 'MIT' 12 | 13 | gem.add_runtime_dependency 'omniauth-oauth2', '~> 1.1' 14 | gem.required_ruby_version = '>= 1.8.7' 15 | 16 | gem.files = `git ls-files`.split($\) 17 | gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) 18 | gem.require_paths = [ 'lib' ] 19 | gem.version = Omniauth::Disqus::VERSION 20 | end 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Ivan Correces 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Omniauth::Disqus 2 | 3 | [![Gem Version](http://img.shields.io/gem/v/omniauth-disqus.svg)][gem] 4 | 5 | [gem]: https://rubygems.org/gems/omniauth-disqus 6 | 7 | A Disqus OAuth2 strategy for OmniAuth. 8 | 9 | ## Installation 10 | 11 | Add this line to your application's Gemfile: 12 | 13 | gem 'omniauth-disqus' 14 | 15 | And then execute: 16 | 17 | $ bundle 18 | 19 | Or install it yourself as: 20 | 21 | $ gem install omniauth-disqus 22 | 23 | ## Usage 24 | 25 | Register your application with Disqus to retrieve a public key and secret key: http://disqus.com/api/applications/ 26 | 27 | This is an example that you might put into a Rails initializer at `config/initializers/omniauth.rb`: 28 | 29 | ```ruby 30 | Rails.application.config.middleware.use OmniAuth::Builder do 31 | provider :disqus, ENV['DISQUS_PUBLIC_KEY'], ENV['DISQUS_SECRET_KEY'], :scope => 'read,email' 32 | end 33 | ``` 34 | 35 | You can now access the OmniAuth Disqus OAuth2 URL: `/auth/disqus`. 36 | 37 | ## Contributing 38 | 39 | 1. Fork it 40 | 2. Create your feature branch (`git checkout -b feature/my-new-feature`) 41 | 3. Commit your changes (`git commit -am 'Added some feature'`) 42 | 4. Push to the branch (`git push origin feature/my-new-feature`) 43 | 5. Create new Pull Request 44 | -------------------------------------------------------------------------------- /lib/omniauth/strategies/disqus.rb: -------------------------------------------------------------------------------- 1 | require 'omniauth-oauth2' 2 | 3 | module OmniAuth 4 | module Strategies 5 | class Disqus < OmniAuth::Strategies::OAuth2 6 | option :name, 'disqus' 7 | option :scope, 'read' 8 | 9 | option :client_options, { 10 | :site => 'https://disqus.com', 11 | :authorize_url => '/api/oauth/2.0/authorize/', 12 | :token_url => '/api/oauth/2.0/access_token/' 13 | } 14 | 15 | uid { access_token.params['user_id'] } 16 | 17 | info do 18 | { 19 | :name => raw_info['name'], 20 | :nickname => raw_info['username'], 21 | :email => raw_info['email'], 22 | :location => raw_info['location'], 23 | :description => raw_info['about'], 24 | :image => raw_info['avatar']['small']['permalink'], 25 | :urls => { 26 | 'profileUrl' => raw_info['profileUrl'] 27 | } 28 | } 29 | end 30 | 31 | extra do 32 | { 33 | :raw_info => raw_info 34 | } 35 | end 36 | 37 | def callback_url 38 | full_host + script_name + callback_path 39 | end 40 | 41 | def raw_info 42 | url = '/api/3.0/users/details.json' 43 | params = { 44 | 'api_key' => access_token.client.id, 45 | 'access_token' => access_token.token 46 | } 47 | 48 | @raw_info ||= access_token.get(url, :params => params).parsed['response'] 49 | end 50 | end 51 | end 52 | end 53 | --------------------------------------------------------------------------------