omniauth-netflix 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gemtest ADDED
File without changes
data/.gitignore ADDED
@@ -0,0 +1,40 @@
1
+ *.gem
2
+ *.rbc
3
+ *.sw[a-p]
4
+ *.tmproj
5
+ *.tmproject
6
+ *.un~
7
+ *~
8
+ .DS_Store
9
+ .Spotlight-V100
10
+ .Trashes
11
+ ._*
12
+ .bundle
13
+ .config
14
+ .directory
15
+ .elc
16
+ .emacs.desktop
17
+ .emacs.desktop.lock
18
+ .redcar
19
+ .yardoc
20
+ Desktop.ini
21
+ Gemfile.lock
22
+ Icon?
23
+ InstalledFiles
24
+ Session.vim
25
+ Thumbs.db
26
+ \#*\#
27
+ _yardoc
28
+ auto-save-list
29
+ coverage
30
+ doc
31
+ lib/bundler/man
32
+ pkg
33
+ pkg/*
34
+ rdoc
35
+ spec/reports
36
+ test/tmp
37
+ test/version_tmp
38
+ tmp
39
+ tmtags
40
+ tramp
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format=nested
3
+ --backtrace
data/.simplecov ADDED
@@ -0,0 +1 @@
1
+ SimpleCov.start
data/.yardopts ADDED
@@ -0,0 +1,3 @@
1
+ --markup markdown
2
+ -
3
+ LICENSE.md
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Steve Agalloco
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # OmniAuth Netflix
2
+
3
+ This gem is an OmniAuth 1.0 Strategy for the [Netflix API](http://developer.netflix.com/)
4
+
5
+ It supports the Netflix REST API which uses OAuth 1.0a.
6
+
7
+ ## Usage
8
+
9
+ Add the strategy to your `Gemfile` alongside OmniAuth:
10
+
11
+ ```ruby
12
+ gem 'omniauth'
13
+ gem 'omniauth-netflix'
14
+ ```
15
+
16
+ Then integrate the strategy into your middleware:
17
+
18
+ ```ruby
19
+ use OmniAuth::Builder do
20
+ provider :netflix, ENV['NETFLIX_KEY'], ENV['NETFLIX_SECRET']
21
+ end
22
+ ```
23
+
24
+ In Rails, you'll want to add to the middleware stack:
25
+
26
+ ```ruby
27
+ Rails.application.config.middleware.use OmniAuth::Builder do
28
+ provider :netflix, ENV['NETFLIX_KEY'], ENV['NETFLIX_SECRET']
29
+ end
30
+ ```
31
+
32
+ You will have to put in your consumer key and secret (Netflix refers to them as Key and Shared Secret).
33
+
34
+ For additional information, refer to the [OmniAuth wiki](https://github.com/intridea/omniauth/wiki).
35
+
36
+ ## <a name="build"></a>Build Status
37
+ [![Build Status](https://secure.travis-ci.org/spagalloco/omniauth-netflix.png?branch=master)][travis]
38
+
39
+ [travis]: http://travis-ci.org/spagalloco/omniauth-netflix
40
+
41
+ ## <a name="dependencies"></a>Dependency Status
42
+ [![Dependency Status](https://gemnasium.com/spagalloco/omniauth-netflix.png?travis)][gemnasium]
43
+
44
+ [gemnasium]: https://gemnasium.com/spagalloco/omniauth-netflix
45
+
46
+ ## Contributing
47
+
48
+ * Fork the project.
49
+ * Make your feature addition or bug fix.
50
+ * Add tests for it. This is important so I don't break it in a
51
+ future version unintentionally.
52
+ * Commit, do not mess with rakefile, version, or history.
53
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
54
+ * Send me a pull request. Bonus points for topic branches.
55
+
56
+ ## Copyright
57
+
58
+ Copyright (c) 2011 Steve Agalloco. See [LICENSE](https://github.com/spagalloco/omniauth-netflix/blob/master/LICENSE.md) for details.
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require 'bundler'
4
+ Bundler::GemHelper.install_tasks
5
+
6
+ require 'rspec/core/rake_task'
7
+ RSpec::Core::RakeTask.new(:spec)
8
+
9
+ task :default => :spec
10
+ task :test => :spec
11
+
12
+ require 'yard'
13
+ namespace :doc do
14
+ YARD::Rake::YardocTask.new do |task|
15
+ task.files = ['LICENSE.md', 'lib/**/*.rb']
16
+ task.options = ['--markup', 'markdown']
17
+ end
18
+ end
data/example/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :rubygems
2
+
3
+ gem 'sinatra'
4
+ gem 'omniauth-netflix', :path => '../'
data/example/config.ru ADDED
@@ -0,0 +1,30 @@
1
+ require 'bundler/setup'
2
+ require 'sinatra/base'
3
+ require 'omniauth-netflix'
4
+
5
+ class App < Sinatra::Base
6
+ get '/' do
7
+ redirect '/auth/netflix'
8
+ end
9
+
10
+ get '/auth/:provider/callback' do
11
+ content_type 'application/json'
12
+ MultiJson.encode(request.env)
13
+ end
14
+
15
+ get '/auth/failure' do
16
+ content_type 'application/json'
17
+ MultiJson.encode(request.env)
18
+ end
19
+ end
20
+
21
+ use Rack::Session::Cookie
22
+
23
+ ENV['APP_ID'] = 'qkfp2sgah9s2fa2ka2yyjj3e'
24
+ ENV['APP_SECRET'] = 'yMqKxTpg2N'
25
+
26
+ use OmniAuth::Builder do
27
+ provider :netflix, ENV['APP_ID'], ENV['APP_SECRET']
28
+ end
29
+
30
+ run App.new
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Netflix
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1 @@
1
+ require 'omniauth/strategies/netflix'
@@ -0,0 +1,51 @@
1
+ require 'omniauth-oauth'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Netflix < OmniAuth::Strategies::OAuth
6
+ option :client_options, {
7
+ :site => 'http://api.netflix.com',
8
+ :authorize_url => 'https://api-user.netflix.com/oauth/login',
9
+ :request_token_url => 'http://api.netflix.com/oauth/request_token',
10
+ :access_token_url => 'http://api.netflix.com/oauth/access_token'
11
+ }
12
+
13
+ uid { raw_info['user']['user_id'] }
14
+
15
+ info do
16
+ {
17
+ 'nickname' => raw_info['user']['nickname'],
18
+ 'first_name' => raw_info['user']['first_name'],
19
+ 'last_name' => raw_info['user']['last_name'],
20
+ 'name' => "#{raw_info['user']['first_name']} #{raw_info['user']['last_name']}"
21
+ }
22
+ end
23
+
24
+ extra do
25
+ { 'raw_info' => raw_info }
26
+ end
27
+
28
+ def request_phase
29
+ request_token = consumer.get_request_token(:oauth_callback => callback_url)
30
+ session['oauth'] ||= {}
31
+ session['oauth'][name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?, 'request_token' => request_token.token, 'request_secret' => request_token.secret}
32
+
33
+ if request_token.callback_confirmed?
34
+ redirect request_token.authorize_url(options[:authorize_params].merge(:oauth_consumer_key => consumer.key))
35
+ else
36
+ redirect request_token.authorize_url(options[:authorize_params].merge(:oauth_callback => callback_url, :oauth_consumer_key => consumer.key))
37
+ end
38
+
39
+ rescue ::Timeout::Error => e
40
+ fail!(:timeout, e)
41
+ rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e
42
+ fail!(:service_unavailable, e)
43
+ end
44
+
45
+ def raw_info
46
+ @raw_info ||= MultiJson.decode(access_token.get("http://api.netflix.com/users/#{@access_token.params[:user_id]}?output=json").body)
47
+ end
48
+
49
+ end
50
+ end
51
+ end
@@ -0,0 +1 @@
1
+ require 'omniauth/netflix'
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+ require File.expand_path('../lib/omniauth/netflix/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = 'omniauth-netflix'
6
+ gem.version = OmniAuth::Netflix::VERSION
7
+ gem.homepage = 'https://github.com/spagalloco/omniauth-netflix'
8
+
9
+ gem.author = "Steve Agalloco"
10
+ gem.email = 'steve.agalloco@gmail.com'
11
+ gem.description = 'Netflix strategy for OmniAuth 1.0'
12
+ gem.summary = gem.description
13
+
14
+ gem.add_dependency "omniauth-oauth", "~> 1.0"
15
+ gem.add_dependency 'multi_json', '~> 1.0'
16
+
17
+ gem.add_development_dependency 'rake', '~> 0.9'
18
+ gem.add_development_dependency 'rdiscount', '~> 1.6'
19
+ gem.add_development_dependency 'rspec', '~> 2.7'
20
+ gem.add_development_dependency 'simplecov', '~> 0.5'
21
+ gem.add_development_dependency 'yard', '~> 0.7'
22
+ gem.add_development_dependency 'webmock', '~> 1.7'
23
+
24
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
25
+ gem.files = `git ls-files`.split("\n")
26
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
27
+
28
+ gem.require_paths = ['lib']
29
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'OmniAuth::Strategies::Netflix Integration' do
4
+ pending 'write some tests yo'
5
+ end
@@ -0,0 +1,75 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Netflix do
4
+ before :each do
5
+ @request = double('Request')
6
+ @request.stub(:params) { {} }
7
+ end
8
+
9
+ subject do
10
+ OmniAuth::Strategies::Netflix.new(nil, @options || {}).tap do |strategy|
11
+ strategy.stub(:request) { @request }
12
+ end
13
+ end
14
+
15
+ describe '#client_options' do
16
+ it 'has correct Netflix site' do
17
+ subject.options.client_options.site.should eq('http://api.netflix.com')
18
+ end
19
+
20
+ it 'has correct authorize url' do
21
+ subject.options.client_options.authorize_url.should eq('https://api-user.netflix.com/oauth/login')
22
+ end
23
+
24
+ it 'has correct request token url' do
25
+ subject.options.client_options.request_token_url.should eq('http://api.netflix.com/oauth/request_token')
26
+ end
27
+
28
+ it 'has correct access token url' do
29
+ subject.options.client_options.access_token_url.should eq('http://api.netflix.com/oauth/access_token')
30
+ end
31
+ end
32
+
33
+ describe '#uid' do
34
+ it 'returns the uid from raw_info' do
35
+ subject.stub(:raw_info) {{ 'user' => { 'user_id' => '123' } } }
36
+ subject.uid.should eq('123')
37
+ end
38
+ end
39
+
40
+ describe '#info' do
41
+ before :each do
42
+ @raw_info ||= { 'user' => { 'first_name' => 'Fred', 'last_name' => 'Smith', 'nickname' => 'freddy' } }
43
+ subject.stub(:raw_info) { @raw_info }
44
+ end
45
+
46
+ context 'when data is present in raw info' do
47
+ it 'returns the name' do
48
+ subject.info['name'].should eq('Fred Smith')
49
+ end
50
+
51
+ it 'returns the first name' do
52
+ subject.info['first_name'].should eq('Fred')
53
+ end
54
+
55
+ it 'returns the last name' do
56
+ subject.info['last_name'].should eq('Smith')
57
+ end
58
+
59
+ it 'returns the nickname' do
60
+ subject.info['nickname'].should eq('freddy')
61
+ end
62
+ end
63
+ end
64
+
65
+ describe '#extra' do
66
+ before :each do
67
+ @raw_info_hash = { "links" => [:link => "http://api.netflix.com/users/T1PambOVJXcoWzNRQEyacp76BnRn0TIJdxKGyklbY0srg-/queues"] }
68
+ subject.stub(:raw_info) { @raw_info_hash }
69
+ end
70
+
71
+ it 'returns a Hash' do
72
+ subject.extra.should be_a(Hash)
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,6 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'simplecov'
4
+ require 'omniauth-netflix'
5
+ require 'rspec'
6
+ require 'webmock/rspec'
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-netflix
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Steve Agalloco
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-12-14 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth-oauth
16
+ requirement: &70152997657720 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70152997657720
25
+ - !ruby/object:Gem::Dependency
26
+ name: multi_json
27
+ requirement: &70152997657100 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '1.0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70152997657100
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &70152997656520 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '0.9'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70152997656520
47
+ - !ruby/object:Gem::Dependency
48
+ name: rdiscount
49
+ requirement: &70152997655940 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70152997655940
58
+ - !ruby/object:Gem::Dependency
59
+ name: rspec
60
+ requirement: &70152997655360 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: '2.7'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70152997655360
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: &70152997654840 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: '0.5'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70152997654840
80
+ - !ruby/object:Gem::Dependency
81
+ name: yard
82
+ requirement: &70152997654340 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: '0.7'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *70152997654340
91
+ - !ruby/object:Gem::Dependency
92
+ name: webmock
93
+ requirement: &70152997653760 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ version: '1.7'
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *70152997653760
102
+ description: Netflix strategy for OmniAuth 1.0
103
+ email: steve.agalloco@gmail.com
104
+ executables: []
105
+ extensions: []
106
+ extra_rdoc_files: []
107
+ files:
108
+ - .gemtest
109
+ - .gitignore
110
+ - .rspec
111
+ - .simplecov
112
+ - .yardopts
113
+ - Gemfile
114
+ - LICENSE.md
115
+ - README.md
116
+ - Rakefile
117
+ - example/Gemfile
118
+ - example/config.ru
119
+ - lib/omniauth-netflix.rb
120
+ - lib/omniauth/netflix.rb
121
+ - lib/omniauth/netflix/version.rb
122
+ - lib/omniauth/strategies/netflix.rb
123
+ - omniauth-netflix.gemspec
124
+ - spec/integration_spec.rb
125
+ - spec/omniauth/strategies/netflix_spec.rb
126
+ - spec/spec_helper.rb
127
+ homepage: https://github.com/spagalloco/omniauth-netflix
128
+ licenses: []
129
+ post_install_message:
130
+ rdoc_options: []
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ none: false
135
+ requirements:
136
+ - - ! '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ required_rubygems_version: !ruby/object:Gem::Requirement
140
+ none: false
141
+ requirements:
142
+ - - ! '>='
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ requirements: []
146
+ rubyforge_project:
147
+ rubygems_version: 1.8.10
148
+ signing_key:
149
+ specification_version: 3
150
+ summary: Netflix strategy for OmniAuth 1.0
151
+ test_files:
152
+ - spec/integration_spec.rb
153
+ - spec/omniauth/strategies/netflix_spec.rb
154
+ - spec/spec_helper.rb
155
+ has_rdoc: