omniauth-rdio-oauth2 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8974a4bb261fb3c7a169fb96e073479d858c4680
4
+ data.tar.gz: 4bcc2330f1f512e25d3fdfe2c47109774a3391d7
5
+ SHA512:
6
+ metadata.gz: bdc48d55f26cdf836641f76eba9bc0755b0b1a09f396d106ecac4878d88d7f810d62f77a5182ebe4f3a7f183a8a2e0c5067cbfdfbe99730bcdbe4c230253cb9a
7
+ data.tar.gz: 475b37fbc4d33592bdc545ede8559407cac53f34df8d00785f56764a6747e87013003e76b06227880ce70fb62e49c8ef5da01c7185dc1df225554ae79520b084
@@ -0,0 +1 @@
1
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Robert Long
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.
@@ -0,0 +1,25 @@
1
+ omniauth-rdio-oauth2
2
+ --------------------
3
+
4
+ An Omniauth Strategy for Rdio's OAuth2 API/ Beta JS API
5
+
6
+ This gem is mostly untested. Use at your own risk.
7
+
8
+ ## Installation
9
+
10
+ Add to your `Gemfile`:
11
+
12
+ ```ruby
13
+ gem 'omniauth-rdio-oauth2'
14
+ ```
15
+
16
+ Then `bundle install`.
17
+
18
+ ## Usage
19
+
20
+ Here's an example for adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
21
+
22
+ ```ruby
23
+ Rails.application.config.middleware.use OmniAuth::Builder do
24
+ provider :rdio_oauth2, ENV["RDIO_CLIENT_ID"], ENV["RDIO_CLIENT_SECRET"]
25
+ end
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ require 'sinatra'
2
+ require 'omniauth'
3
+ require 'omniauth-rdio-oauth2'
4
+
5
+ use Rack::Session::Cookie
6
+ use OmniAuth::Builder do
7
+ provider :rdio_oauth2, "CLIENT_ID", "CLIENT_SECRET"
8
+ end
9
+
10
+ get '/' do
11
+ <<-HTML
12
+ <a href='/auth/rdio_oauth2'>Sign in with Rdio</a>
13
+ HTML
14
+ end
15
+
16
+ get '/auth/rdio_oauth2/callback' do
17
+ auth = request.env['omniauth.auth']
18
+ redirect '/'
19
+ end
20
+
21
+ get '/auth/failure' do
22
+ puts params[:message]
23
+ redirect '/'
24
+ end
@@ -0,0 +1 @@
1
+ require 'omniauth/strategies/rdio_oauth2'
@@ -0,0 +1,43 @@
1
+ require 'omniauth-oauth2'
2
+ require 'net/http'
3
+ require 'multi_json'
4
+
5
+ module OmniAuth
6
+ module Strategies
7
+ class RdioOauth2 < OmniAuth::Strategies::OAuth2
8
+
9
+ option :name, 'rdio_oauth2'
10
+
11
+ option :client_options, {
12
+ site: 'https://www.rdio.com/api/1/',
13
+ authorize_url: 'https://www.rdio.com/oauth2/authorize',
14
+ token_url: 'https://www.rdio.com/oauth2/token'
15
+ }
16
+
17
+ uid { user_data['key'] }
18
+
19
+ info do
20
+ {
21
+ first_name: user_data['firstName'],
22
+ last_name: user_data['lastName'],
23
+ icon: user_data['icon'],
24
+ email: user_data['email'],
25
+ gender: user_data['gender'],
26
+ key: user_data['key']
27
+ }
28
+ end
29
+
30
+ extra do
31
+ { :user_data => user_data }
32
+ end
33
+
34
+ EXTRAS = 'email,followingUrl,isTrial,artistCount,heavyRotationKey,networkHeavyRotationKey,albumCount,trackCount,username,collectionUrl,playlistsUrl,collectionKey,followersUrl,displayName,isUnlimited,isSubscriber'
35
+
36
+ def user_data
37
+ uri = URI('https://www.rdio.com/api/1/')
38
+ res = Net::HTTP.post_form(uri, 'method' => 'currentUser', 'extras' => EXTRAS, 'access_token' => access_token.token)
39
+ @user_data ||= MultiJson.decode(res.body)['result']
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.name = 'omniauth-rdio-oauth2'
5
+ gem.version = '0.1.2'
6
+ gem.author = 'Robert Long'
7
+ gem.email = 'robert@robertlong.me'
8
+ gem.license = 'MIT'
9
+ gem.homepage = 'https://github.com/robertlong/omniauth-rdio-oauth2'
10
+ gem.summary = 'OmniAuth strategy for Rdio OAuth2'
11
+ gem.description = 'OmniAuth strategy for Rdio OAuth2'
12
+
13
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
14
+ gem.files = `git ls-files`.split("\n")
15
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ gem.require_paths = ['lib']
17
+
18
+ # Dependencies
19
+ gem.add_runtime_dependency 'omniauth-oauth2'
20
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-rdio-oauth2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Robert Long
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth-oauth2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: OmniAuth strategy for Rdio OAuth2
28
+ email: robert@robertlong.me
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - .gitignore
34
+ - Gemfile
35
+ - LICENSE
36
+ - README.md
37
+ - Rakefile
38
+ - example/auth.rb
39
+ - lib/omniauth-rdio-oauth2.rb
40
+ - lib/omniauth/strategies/rdio_oauth2.rb
41
+ - omniauth-rdio-oauth2.gemspec
42
+ homepage: https://github.com/robertlong/omniauth-rdio-oauth2
43
+ licenses:
44
+ - MIT
45
+ metadata: {}
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubyforge_project:
62
+ rubygems_version: 2.2.1
63
+ signing_key:
64
+ specification_version: 4
65
+ summary: OmniAuth strategy for Rdio OAuth2
66
+ test_files: []