├── .gitignore ├── Gemfile ├── lib ├── omniauth-genius.rb ├── omniauth-genius │ └── version.rb └── omniauth │ └── strategies │ └── genius.rb ├── omniauth-genius.gemspec └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | Gemfile.lock 2 | *.gem 3 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gemspec 4 | -------------------------------------------------------------------------------- /lib/omniauth-genius.rb: -------------------------------------------------------------------------------- 1 | require_relative 'omniauth/strategies/genius' 2 | -------------------------------------------------------------------------------- /lib/omniauth-genius/version.rb: -------------------------------------------------------------------------------- 1 | module OmniAuth 2 | module Genius 3 | VERSION = '0.0.1' 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /omniauth-genius.gemspec: -------------------------------------------------------------------------------- 1 | lib = File.expand_path('../lib', __FILE__) 2 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 3 | require 'omniauth-genius/version' 4 | 5 | Gem::Specification.new do |gem| 6 | gem.name ='omniauth-genius' 7 | gem.authors = ['john@genius.com'] 8 | gem.version = OmniAuth::Genius::VERSION 9 | gem.summary = 'OmniAuth Strategy for Genius' 10 | 11 | gem.add_runtime_dependency 'omniauth', '~> 1.0' 12 | gem.add_runtime_dependency 'omniauth-oauth2', '~> 1.0' 13 | end 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # omniauth-genius 2 | 3 | An OmniAuth strategy for authenticating with the Genius API. 4 | 5 | ## Installation 6 | 7 | In your Gemfile: 8 | 9 | ``` ruby 10 | gem 'omniauth-genius' 11 | ``` 12 | 13 | ## Usage 14 | 15 | Here's an example on setting up `omniauth-genius` (NOTE: this should be placed 16 | in something like `config/initializers/omniauth.rb`: 17 | 18 | ``` ruby 19 | Rails.application.config.middleware.use OmniAuth::Builder do 20 | provider :genius, ENV['GENIUS_CLIENT_ID'], ENV['GENIUS_CLIENT_SECRET'] 21 | end 22 | ``` 23 | 24 | ## Helpful Links 25 | 26 | * [Documentation](https://docs.genius.com) 27 | * [API Clients](http://genius.com/api-clients) 28 | -------------------------------------------------------------------------------- /lib/omniauth/strategies/genius.rb: -------------------------------------------------------------------------------- 1 | require 'omniauth-oauth2' 2 | 3 | module OmniAuth 4 | module Strategies 5 | class Genius < OmniAuth::Strategies::OAuth2 6 | 7 | option :name, 'genius' 8 | 9 | option :client_options, { 10 | site: 'https://api.genius.com' 11 | } 12 | 13 | uid do 14 | raw_info['id'] 15 | end 16 | 17 | info do 18 | { 19 | :id => raw_info['id'], 20 | :name => raw_info['name'], 21 | :login => raw_info['login'], 22 | :iq => raw_info['iq'] 23 | } 24 | end 25 | 26 | extra do 27 | raw_info 28 | end 29 | 30 | def raw_info 31 | @raw_info ||= access_token.get('/account').parsed['response']['user'] 32 | end 33 | 34 | end 35 | end 36 | end 37 | --------------------------------------------------------------------------------